> For the complete documentation index, see [llms.txt](https://docs.winga.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.winga.me/integrations/go.md).

# Go

There is no dedicated Winga SDK for Go. Use the [Evaluation API](/api-reference/evaluation-api.md) directly with `net/http`. Load the flag map once at startup, then read it.

```go
package winga

import (
  "encoding/json"
  "net/http"
)

type FlagState struct {
  Enabled bool `json:"enabled"`
}

type Client struct {
  apiKey      string
  environment string
  flags       map[string]FlagState
}

func New(apiKey, environment string) *Client {
  return &Client{apiKey: apiKey, environment: environment}
}

func (c *Client) Load() error {
  req, _ := http.NewRequest("GET",
    "https://api.winga.me/v1/flags?env="+c.environment, nil)
  req.Header.Set("X-Winga-Key", c.apiKey)

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    return err
  }
  defer resp.Body.Close()

  var body struct {
    Flags map[string]FlagState `json:"flags"`
  }
  if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
    return err
  }
  c.flags = body.Flags
  return nil
}

func (c *Client) IsEnabled(key string) bool {
  return c.flags[key].Enabled
}
```

```go
// Usage
ff := winga.New("proj_live_xxx", "production")
if err := ff.Load(); err != nil {
  log.Fatal(err)
}

if ff.IsEnabled("new-checkout") {
  // ...
}
```

For realtime updates, read the `GET /v1/stream?env=<environment>` SSE response line by line and re-decode the flag map on each `data:` frame.
