go and toolchain directives
Set `go` to the minimum language expectation and use `toolchain` only when developer ergonomics need a newer default toolchain.
Canonical guidance
- keep
gohonest about the minimum version the module needs - use
toolchainonly when the default developer toolchain should be newer - review both directives when adopting new language or library features
Use when
- upgrading Go versions
- enabling new language features
- standardizing local toolchains across contributors
Avoid
- bumping
gocasually without using the new requirement - using
toolchainto paper over incorrect version requirements - forgetting that older consumers read the
godirective as compatibility signal
Preferred pattern
module example.com/app
go 1.23
toolchain go1.25.3
Anti-pattern
- setting
goto the newest company toolchain even though the module only needs an older language baseline
Explanation: This anti-pattern is tempting because standardization feels neat, but it raises the compatibility floor without a real reason.
Why
- these directives communicate compatibility and toolchain expectations to both humans and tooling
Related pages
Sources
- Go Modules Reference - Go Team