Skip to content

Go Configuration

The Go SDK uses functional options for configuration:

client := flags.NewClient(
flags.WithAuth(flags.Auth{
ProjectID: "your-project-id",
AgentID: "your-agent-id",
EnvironmentID: "your-environment-id",
}),
flags.WithBaseURL("https://custom-api.flags.gg"),
flags.WithMaxRetries(5),
flags.WithMemory(),
)
OptionDefaultDescription
WithAuth(Auth)Required. Set project, agent, and environment IDs
WithBaseURL(string)https://api.flags.ggCustom API endpoint
WithMaxRetries(int)3Max retry attempts on failure
WithMemory()SQLiteUse in-memory cache instead of SQLite
SetFileName(*string)/tmp/flags.dbCustom SQLite database path

The client is safe for concurrent use. All operations use sync.RWMutex internally.

The client handles errors gracefully:

  • API failures fall back to cached values
  • Unknown flags return false (disabled)
  • The circuit breaker prevents cascading failures after 3 consecutive errors