RudderTyper v2 Adds Go Bindings

Generate typed Go calls from Tracking Plans with RudderTyper v2 and the RudderStack Go SDK.
Available Plans
  • free
  • growth
  • enterprise

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/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.
DocumentationDescription
RudderTyper v2 OverviewPlatform support and limitations
RudderTyper v2 Command ReferenceGo flags, options, types, and generated names
RudderTyper v2 WalkthroughSetup, calls, and error handling

Questions? Let's figure it out together.

Join the RudderStack Slack community to connect with other users, customers, and the RudderStack team — or reach out for direct support.