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:
Configuration
Section titled “Configuration”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-08Common configuration options
Section titled “Common configuration options”targets: go: module_path: github.com/my-org/my-sdk-go
# Specify the edition edition: go.2025-10-08For a complete list of configuration options, see the Go target reference.
Module path
Section titled “Module path”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.
Versioning considerations
Section titled “Versioning considerations”Editions
Section titled “Editions”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.
go.2025-10-08
Section titled “go.2025-10-08”- Initial edition for Go (used by default if no edition is specified)
Publishing
Section titled “Publishing”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:
- Stainless creates a git tag with the version number (e.g.,
v1.2.3) - GoReleaser builds and publishes your release
- The Go module proxy automatically caches your module
- Your package documentation appears on pkg.go.dev
Troubleshooting
Section titled “Troubleshooting”Package not appearing on pkg.go.dev
Section titled “Package not appearing 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:
- Verify the GitHub repository is public
- Check that git tags exist with the
vprefix (e.g.,v1.0.0, not1.0.0) - Ensure the
module_pathin your config matches your repository URL exactly - Wait 5-10 minutes for the Go proxy to cache new releases
Stale versions in user environments
Section titled “Stale versions in user environments”Users may have cached old versions. They can clear their local module cache with:
go clean -modcache