Skip to content
FeedbackDashboard
Codegen targets

Go

Generate production-ready Go SDKs from your OpenAPI specification

The Stainless Go SDK generator creates idiomatic, type-safe Go client libraries from your OpenAPI specification.

Example repositories:

To generate a Go SDK, add the go target to your Stainless configuration file:

targets:
go:
module_path: github.com/my-org/my-sdk-go
edition: go.2025-10-08
targets:
go:
module_path: github.com/my-org/my-sdk-go
# Specify the edition
edition: go.2025-10-08

For a complete list of configuration options, see the Go target reference.

The module_path is the import path users type in their Go code:

import "github.com/my-org/my-sdk-go"

This path must match your GitHub repository URL. For example, if your repo is github.com/acme/acme-go, your module path should be github.com/acme/acme-go.

Editions allow Stainless to make improvements to SDKs that aren’t backwards-compatible. You can explicitly opt in to new editions when you’re ready. See the SDK and config editions reference for more information.

  • Initial edition for Go (used by default if no edition is specified)

Go installs packages directly from source repositories, so publishing is simpler than other languages—no package registry upload required. Stainless uses GoReleaser to build and publish your SDK.

For details on how Stainless opens Release PRs and manages versioning, see Versioning and releases.

When you merge a Release PR:

  1. Stainless creates a git tag with the version number (e.g., v1.2.3)
  2. GoReleaser builds and publishes your release
  3. The Go module proxy automatically caches your module
  4. Your package documentation appears on pkg.go.dev

After your first release, manually trigger indexing by visiting https://pkg.go.dev/github.com/<your-org>/<your-repo> and clicking Request. Allow a few minutes for indexing to complete.

Users getting “module not found” errors

Section titled “Users getting “module not found” errors”

If users report they can’t install your SDK:

  1. Verify the GitHub repository is public
  2. Check that git tags exist with the v prefix (e.g., v1.0.0, not 1.0.0)
  3. Ensure the module_path in your config matches your repository URL exactly
  4. Wait 5-10 minutes for the Go proxy to cache new releases

Users may have cached old versions. They can clear their local module cache with:

Terminal window
go clean -modcache