Hacker News new | ask | show | jobs
by veber-alex 1098 days ago
It is different.

The rustup toolchain toml file is under your control, dependencies have no affect on it.

This Go feature is like the rust-version key in Cargo.toml where if a dependency specifies in it's own Cargo.toml file that it needs a rust version higher than you what you have you will get an error and your code won't compile (there is no option to auto upgrade the toolchain in rust).

1 comments

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).
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