Hacker News new | ask | show | jobs
by GeneralMayhem 1097 days ago
This is incorrect afaict. The Go docs specify that the toolchain directive is only considered in the "main" module. If your dependencies set it, it has no effect (unless they're binary tool dependencies that you go install).
1 comments

According to the docs[0] you can't declare a go version in the main module or workspace that is lower then the go version of one of your dependencies.

  A module’s go line must declare a version greater than or equal to the go version declared by each of the 
  modules listed in require statements. A workspace’s go line must declare a version greater than or equal 
  to the go version declared by each of the modules listed in use statements.
  
  For example, if module M requires a dependency D with a go.mod that declares go 1.22.0, then M’s go.mod 
  cannot say go 1.21.3.
so the "go" directive is like "rust-version" in Cargo.toml and the "toolchain" directive is like the rust version in a rust-toolchain file.

[0]: https://tip.golang.org/doc/toolchain