Go Quickstart

Add license validation to any Go application — CLI tools, APIs, or desktop apps.

5 minute setup
$ go get github.com/TrafficOrchestrator/go-sdk
1

Install the SDK

Add the Traffic Orchestrator Go module to your project.

bash
# Go modules
go get github.com/TrafficOrchestrator/go-sdk
2

Initialize the Client

Create a client instance pointing at the Traffic Orchestrator API.

go
package main

import (
    to "github.com/TrafficOrchestrator/go-sdk"
)

func main() {
    client := to.NewClient("https://api.trafficorchestrator.com/api/v1")
}
3

Validate a License Key

Check if a license key is valid. Returns the license status and enabled features.

go
result, err := client.Validate(to.ValidateRequest{
    Key:    "TO-XXXX-XXXX-XXXX",
    Domain: "example.com",
})

if err != nil {
    log.Fatal(err)
}

if result.Valid {
    fmt.Println("✅ License active!", result.Features)
} else {
    fmt.Println("❌ Invalid:", result.Error)
}
4

Activate on a Device

Register a machine against the license to enforce seat limits.

go
import "crypto/sha256"

// Generate a stable machine fingerprint
hostname, _ := os.Hostname()
hash := sha256.Sum256([]byte(hostname))
machineID := fmt.Sprintf("%x", hash[:16])

activation, err := client.Activate(to.ActivateRequest{
    Key:       "TO-XXXX-XXXX-XXXX",
    MachineID: machineID,
})

fmt.Printf("Seats: %d/%d\n", activation.Activations, activation.MaxActivations)