# RudderTyper v2 Adds Go Bindings


> Generate typed Go calls from Tracking Plans with RudderTyper v2 and the RudderStack Go SDK.



[Rudder CLI](https://www.rudderstack.com/docs/releases/rudder-cli/index.md) v1.4.0 adds Go bindings to RudderTyper v2 via `rudder-cli typer generate --platform=go`. Generate from a workspace Tracking Plan or from local specs with `--local --location=<PROJECT_PATH>`. The generated package wraps the RudderStack Go SDK with typed methods and payloads.

## Requirements

- Go 1.21 or later
- `github.com/rudderlabs/analytics-go/v4` v4.2.2 or later
- Rudder CLI v1.4.0 or later

## Generate and use the bindings

Generate into a dedicated package directory:

```bash
rudder-cli typer generate --platform=go --tracking-plan-id=<TRACKING_PLAN_ID> -o internal/ruddertyper
```

Alternatively, generate from local specs with `rudder-cli typer generate --platform=go --local --location=<PROJECT_PATH> -o internal/ruddertyper`. In your Go application, import `analytics "github.com/rudderlabs/analytics-go/v4"` and your generated package as `ruddertyper` from its module path:

```go
client := analytics.New("<WRITE_KEY>", "<DATA_PLANE_URL>")
defer client.Close()

rt := ruddertyper.New(client)
user := ruddertyper.Identity{UserID: "user-123"}

// With properties
err := rt.TrackSomeTrackEvent(user, ruddertyper.TrackSomeTrackEventProperties{SomeString: "hello", SomeInteger: 1})
```

The method and property names depend on your Tracking Plan; this example comes from the generator's compiled sample plan.

## Go-specific behavior

- Keep the generated file alone in its package, never edit it, and regenerate after every Tracking Plan change. Set `packageName` and `outputFileName` with `--option`; list them with `rudder-cli typer options --platform=go`.
- Go cannot enforce that a required struct field was set. An unset field sends its zero value; an unset union without `null`, mixed enum, or variant fails with `ErrInvalidValue`. Use an enum's `IsValid()` for untrusted input: generated code checks shape, not values.
- Every call takes an identity. A `nil` error means queued, not delivered; delivery failures reach the SDK's `Config.Callback`.

| Documentation | Description |
| :---- | :---- |
| [RudderTyper v2 Overview](https://www.rudderstack.com/docs/rudder-cli/ruddertyper-v2/index.md) | Platform support and limitations |
| [RudderTyper v2 Command Reference](https://www.rudderstack.com/docs/rudder-cli/ruddertyper-v2-command-reference/index.md) | Go flags, options, types, and generated names |
| [RudderTyper v2 Walkthrough](https://www.rudderstack.com/docs/rudder-cli/ruddertyper-v2-walkthrough/index.md) | Setup, calls, and error handling |

