RudderTyper v2 Adds Go Bindings
- free
- growth
- enterprise
2 minute read
- Date: Dec 3, 2026
Rudder CLI 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/v4v4.2.2 or later- Rudder CLI v1.4.0 or later
Generate and use the bindings
Generate into a dedicated package directory:
rudder-cli typer generate --platform=go --tracking-plan-id=<TRACKING_PLAN_ID> -o internal/ruddertyperAlternatively, 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:
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
packageNameandoutputFileNamewith--option; list them withrudder-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 withErrInvalidValue. Use an enum’sIsValid()for untrusted input: generated code checks shape, not values. - Every call takes an identity. A
nilerror means queued, not delivered; delivery failures reach the SDK’sConfig.Callback.
| Documentation | Description |
|---|---|
| RudderTyper v2 Overview | Platform support and limitations |
| RudderTyper v2 Command Reference | Go flags, options, types, and generated names |
| RudderTyper v2 Walkthrough | Setup, calls, and error handling |