The official Go client for the XtraSecurity API. Built with goroutine-safe caching, strict typing, and Zero-Trust injection.
The SDK provides a primary struct, Client. It accepts a ClientOptions struct during instantiation via NewClient().
| Option | Type | Default | Description |
|---|---|---|---|
| Token | string | os.Getenv("XTRA_TOKEN") | The API Token used for authentication. |
| ProjectID | string | os.Getenv("XTRA_PROJECT_ID") | The default project ID for all secret operations. |
| APIUrl | string | https://www.xtrasecurity.in/api | Override the base URL for self-hosted Enterprise instances. |
| Cache | bool | true | Enables in-memory caching (goroutine-safe). |
| CacheTTL | time.Duration | 30 * time.Second | Time-to-live for cached secrets. |
Fetches all secrets for a specific environment and branch, returning a map[string]string. This method is goroutine-safe and utilizes the RWMutex cache.
| Parameter | Type | Description |
|---|---|---|
| env | string | Required. The target environment (e.g. "production"). |
| opts | *SecretOptions | Optional struct containing Branch, ProjectID, and NoCache settings. Pass nil for defaults. |
A convenience method that fetches secrets and immediately populates os.Environ() using os.Setenv().
Safely flushes the in-memory secret cache across all goroutines.
For power users building custom internal tools, Client exposes the raw auto-generated service classes.
The Go SDK uses standard Go error handling. Internal SDK errors can be type-asserted to *xtra.Error.