The go-sdk is Hyphen's native Go SDK for evaluating Toggle feature flags in Go applications and services.
Table of Contents
Installation
go get github.com/Hyphen/go-sdk
Authentication
The SDK requires a project public key (it starts with public_) and an application id. See Get a Project's Public Key for where to find these in the Hyphen dashboard.
These can be provided as options during initialization or via environment variables:
HYPHEN_PUBLIC_API_KEY=public_your_api_key
HYPHEN_APPLICATION_ID=your_application_id
Initialization
The SDK uses functional options to configure the client:
client, err := hyphen.New(
hyphen.WithPublicAPIKey("public_your_api_key"),
hyphen.WithApplicationID("your_application_id"),
)
if err != nil {
log.Fatal(err)
}
Usage
Retrieve a boolean feature flag with a default fallback:
result := client.Toggle.GetBoolean(
context.Background(),
"hyphen-sdk-boolean",
false,
nil,
)
fmt.Printf("Boolean toggle value: %v\n", result)
See also
- GitHub: Hyphen/go-sdk
- Prefer OpenFeature? Use the Go provider.