toggly-go
Official Go SDK for Toggly — local feature-flag evaluation with periodic refresh, optional live updates, usage/metrics, and snapshot providers.
What's included
| Package |
Import path |
Purpose |
| Core client |
.../toggly-go/toggly |
NewClient, IsEnabled, variants, usage/metrics |
| Snapshot |
.../toggly-go/toggly/snapshot |
Offline / startup cache (memory, file, Redis, SQLite, Postgres, MongoDB) |
| Session |
.../toggly-go/toggly/session |
Sticky results for percentage rollouts |
| Live updates |
.../toggly-go/toggly/live |
WebSocket refresh |
| Context helpers |
.../toggly-go/togglyctx |
Evaluation context helpers |
| HTTP helpers |
.../toggly-go/togglyhttp |
HTTP integration helpers |
| Templates |
.../toggly-go/togglytemplate |
Template helpers |
Entity ContextProperty filters evaluate EntityContext (kind, key, attributes) and are ANDed with user filters. RegisterContext optionally PUTs schemas to sdk/{appKey}/contexts (opt out with DisableEntityContextRegistration).
Get started
- Create a free app at toggly.io.
- Install the module (Go 1.22+):
go get github.com/ops-ai/Toggly.FeatureManagement/toggly-go@latest
- Evaluate a flag:
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/ops-ai/Toggly.FeatureManagement/toggly-go/toggly"
"github.com/ops-ai/Toggly.FeatureManagement/toggly-go/toggly/session"
)
func main() {
client, err := toggly.NewClient(toggly.Config{
AppKey: "YOUR_APP_KEY",
Environment: "Production",
BaseURL: "https://app.toggly.io/",
DefinitionsURL: "https://definitions.toggly.io/",
SessionStore: session.NewMemoryStore(),
SessionTTL: 30 * time.Minute,
})
if err != nil {
log.Fatal(err)
}
defer func() { _ = client.Close() }()
on, err := client.IsEnabled(context.Background(), "MyFeature", toggly.Context{
Identity: "user-123",
Groups: []string{"beta"},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("MyFeature enabled: %v\n", on)
}
Full example: examples/basic.
Documentation & resources
Contributing
This package lives in the Toggly.FeatureManagement monorepo. Please open an issue first, then follow the root CONTRIBUTING.md.
gofmt -w .
go test ./...
If you change publishable behavior, bump VERSION and update CHANGELOG.md in the same PR.
Security
Report vulnerabilities privately via GitHub Private Vulnerability Reporting. See the monorepo SECURITY.md.
License
MIT