Install
Install on Go
Install the Sankofa Go SDK and instrument net/http or any framework with context-aware tracking.
The Sankofa Go SDK lives at github.com/sankofa-hq/sankofa_sdk_go and is imported as sankofacatch. It focuses on Catch — error capture, transactions, profiling — with net/http middleware. Server-side flag and config evaluation is not built in; the SDK accepts optional ReadFlagSnapshot / ReadConfigSnapshot callbacks so captured error events can include flag context.
Requirements
- Go 1.22+
- Module-aware project (
go.modpresent)
1. Add the package
go get github.com/sankofa-hq/sankofa_sdk_go@latestVerify the import path resolves:
go list -m github.com/sankofa-hq/sankofa_sdk_go2. Construct a client
The SDK does not use a global singleton by default — you construct a client and inject it where it's needed. This makes it straightforward to use in tests and shared libraries.
package main
import (
"context"
"log"
"os"
"github.com/sankofa-hq/sankofa_sdk_go/sankofa"
)
func main() {
client, err := sankofa.New(sankofa.Config{
APIKey: os.Getenv("SANKOFA_KEY"),
Endpoint: "https://api.sankofa.dev",
Release: os.Getenv("RELEASE_SHA"),
Environment: os.Getenv("ENV"),
})
if err != nil {
log.Fatalf("sankofa init: %v", err)
}
defer client.Close(context.Background())
// ... start the server
}client.Close flushes the queue and waits for in-flight uploads — call it from a graceful-shutdown handler so events aren't dropped on exit.
Config options
APIKeystringRequiredEndpointstringdefault https://api.sankofa.devReleasestringEnvironmentstringdefault productionFlushIntervaltime.Durationdefault 5sMaxQueueSizeintdefault 1024HTTPClient*http.Client3. Wire HTTP middleware
The package exposes a net/http middleware that captures request context (method, path, status) and attaches it to every event emitted while serving the request.
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
client.Track(r.Context(), sankofa.Event{
Name: "homepage_visited",
Properties: map[string]any{"path": r.URL.Path},
})
fmt.Fprintln(w, "ok")
})
handler := sankofa.HTTPMiddleware(client)(mux)
http.ListenAndServe(":3000", handler)The middleware is framework-agnostic — wrap any http.Handler with it. Echo, Gin, Chi, and Fiber all expose adapters that fit the http.Handler shape.
4. Verify the install
client.Track(context.Background(), sankofa.Event{
Name: "install_check",
DistinctID: "test-user",
Properties: map[string]any{"from": "go-quickstart"},
})Open app.sankofa.dev → Live events. Within a few seconds you'll see the event with a go source label and the runtime version captured under default properties.