toggly-go

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT

README

toggly-go

Go Reference Documentation Website

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

  1. Create a free app at toggly.io.
  2. Install the module (Go 1.22+):
go get github.com/ops-ai/Toggly.FeatureManagement/toggly-go@latest
  1. 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

Directories

Path Synopsis
examples
basic command
secure
Package secure contains optional secure-feature authorization hooks.
Package secure contains optional secure-feature authorization hooks.
session
Package session contains optional session stickiness primitives.
Package session contains optional session stickiness primitives.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL