Hacker News new | ask | show | jobs
by leighmcculloch 1098 days ago
Go downloading a toolchain is not any different to dustup downloading the version of rust that is in a toolchain toml file. At least with Go it will presumably only download officially released versions, and not gotip/nightly.
3 comments

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

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

It's totally different. In go "go build" will fetch a new toolchain without your asking it to. For that matter it seems every go subcommand will do this (even --help [1]).

[1] https://github.com/golang/go/issues/60956

rustup ?