Stop picking my Go version for me
19 hours ago
- #go directive
- #Go Modules
- #Minimum Version
- The go.mod file's 'go' directive specifies the minimum Go version required to compile the project, not the version used for compilation.
- Including a full patch number (e.g., 1.21.0) since Go 1.21 can incorrectly force transitive dependents to use that specific version, limiting flexibility.
- Tools like GitHub Actions' setup-go should not use the 'go' directive to select the Go version; alternatives like the 'toolchain' directive are recommended.
- The default behavior of 'go mod init' setting the latest version is considered a bad default, and it's better to manually set a lower minimum version.
- Even if a package depends on a specific patch, the directive should only be set to that version if compilation is impossible with earlier versions due to its viral nature.