> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Go SDK - Installation

> Install the Westyx Nexus Go SDK via go get.

The Go SDK is served as a standard Go module. There is **no separate package registry** - `go get` resolves the module directly via `proxy.golang.org`, which caches it from the public GitLab repository.

## Install

```sh theme={null}
go get gitlab.com/westyx/nexus/sdk/go
```

Pin a specific version (recommended for libraries):

```sh theme={null}
go get gitlab.com/westyx/nexus/sdk/go@v0.10.1
```

Add the import to your code:

```go theme={null}
import nexus "gitlab.com/westyx/nexus/sdk/go"
```

The `nexus` alias is conventional - every example in this documentation uses it. Without an alias the package name would also be `nexus` (it's the package name declared in `client.go`), but the explicit alias makes the import path obvious to readers.

## Requirements

* **Go 1.26** or newer
* Network access to `proxy.golang.org` for installation, and to `<your-slug>.westyx.dev` at runtime

## How `go get` resolves this module

1. You declare `gitlab.com/westyx/nexus/sdk/go` in your `go.mod` (either directly or via `go get`).
2. The Go toolchain queries `proxy.golang.org` for the module's metadata.
3. On a cache miss, the proxy fetches the module from the public GitLab repository at the same path and caches it.
4. Subsequent users hit the proxy cache - no GitLab traffic.

This is the **default** Go module flow - it works with no extra configuration on your machine.

## Behind a firewall / `GOPRIVATE`

If `proxy.golang.org` is unreachable from your build environment, set `GOPROXY=direct` (or `GOPROXY=https://your-internal-proxy`) and ensure your build agents can reach `gitlab.com` directly. No authentication is required - the repository is publicly readable.

If your organisation policy treats `gitlab.com` as private:

```sh theme={null}
export GOPRIVATE=gitlab.com/westyx/nexus
```

This tells the toolchain to skip `proxy.golang.org` and `sum.golang.org` for that path prefix, fetching directly via git over HTTPS.

## Verifying installation

```sh theme={null}
go list -m gitlab.com/westyx/nexus/sdk/go
```

Should print:

```
gitlab.com/westyx/nexus/sdk/go v0.9.0
```

If the command reports a different (older) version, run `go get -u gitlab.com/westyx/nexus/sdk/go` to upgrade.

## Verifying connectivity

Before writing any Go code, you can confirm your endpoint and API key are correct with a plain `curl`:

```sh theme={null}
curl -s \
  -H "X-Nexus-API-Key: wxs_..." \
  https://your-service.westyx.dev/v1/sync
```

A valid response returns a JSON snapshot with your `configs`, `secrets`, and `flags`. An `HTTP 401` means the key is wrong; `HTTP 404` means the slug is wrong.

To watch the live SSE stream:

```sh theme={null}
curl -N \
  -H "X-Nexus-API-Key: wxs_..." \
  -H "Accept: text/event-stream" \
  https://your-service.westyx.dev/v1/stream
```

You should see `event:resync` arrive within a second. Press `Ctrl+C` to stop.

## Troubleshooting

<Warning>
  The import path is case-sensitive. The trailing `/go` is part of the path - don't drop it.
</Warning>

* **`module not found`** - check the import path is exactly `gitlab.com/westyx/nexus/sdk/go`.
* **`proxy.golang.org returned 410 Gone`** - typical when a tag is force-deleted. Pin to a known-good version or wait \~30 minutes for the proxy to refresh its cache.
* **`unknown revision v0.X.Y`** - the tag exists locally but `proxy.golang.org` hasn't seen it yet. Wait a minute, then retry; or `GOPROXY=direct go get ...` to bypass the proxy.
