Before installing the Togo MQ SDK, ensure you have:
The official Togo MQ SDK for Go is available via go get:
go get github.com/TogoMQ/togomq-sdk-go
This will download the latest version of the SDK and all its dependencies.
To install a specific version of the SDK:
go get github.com/TogoMQ/togomq-sdk-go@v0.2.3
To update to the latest version:
go get -u github.com/TogoMQ/togomq-sdk-go
Create a simple test file to verify the installation:
test-install.go:
package main
import (
"fmt"
"github.com/TogoMQ/togomq-sdk-go"
)
func main() {
// This will fail without a valid token, but verifies the SDK is installed
config := togomq.NewConfig(
togomq.WithToken("test-token"),
)
fmt.Println("TogoMQ SDK installed successfully!")
fmt.Printf("Config created: %+v\n", config)
}
Run the test:
go run test-install.go
If you see output without import errors, the SDK is installed correctly!
Once installed, you can start using the SDK:
package main
import (
"context"
"log"
"os"
"github.com/TogoMQ/togomq-sdk-go"
)
func main() {
// Create configuration
config := togomq.NewConfig(
togomq.WithToken(os.Getenv("TOGOMQ_TOKEN")),
)
// Create client
client, err := togomq.NewClient(config)
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
defer client.Close()
// Create and publish a message
msg := togomq.NewMessage("test-topic", []byte("Hello, TogoMQ!"))
resp, err := client.PubBatch(context.Background(), []*togomq.Message{msg})
if err != nil {
log.Fatalf("Failed to publish: %v", err)
}
log.Printf("Published %d messages successfully!", resp.MessagesReceived)
}
Before running:
export TOGOMQ_TOKEN="your-token-here"go run main.goWe're actively developing SDKs for additional programming languages:
All SDKs will leverage gRPC for high-performance, type-safe communication with the Togo MQ platform.
The Togo MQ SDK includes:
{success} Next: Learn about Publishing Messages to start sending messages with Togo MQ.