Live data from Hacker News

Stop picking my Go version for me

blog.howardjohn.info

21–30 of 64 posts

Re: Stop picking my Go version for me

#21

How your go.mod should look: go 1.24.0 toolchain go1.25.7 "This module compiles with the language and runtime of go 1.24 and later, but I recommend you use at least go release 1.25.7" go get can manage this for you - https://go.dev/doc/toolchain#get

Thank you so much.

Re: Stop picking my Go version for me

#22
Weird that this needs to be said. I’m not familiar with the Go ecosystem, but there is usually a natural incentive for library developers to reach more people, which means you’d want to support the oldest feasible version. If you don’t do that then someone will develop a better library which does support an older version. Is that not happening here?

Re: Stop picking my Go version for me

#23
post #18

Same situation in Rust crates, AIUI.

I think Rust is slightly different in practice even if they behave the same technically. I'm not sure Rust lets you even set the MSRV to a specific patch which is the biggest annoyance with Go; if they do it's so uncommon I've at least never seen it. And I don't believe any Rust tooling encourages you to set the MSRV to like tools in the Go ecosystem do.

Re: Stop picking my Go version for me

#24
> Its not your responsibility to ensure transitive importers of your library are on the latest version of Go. Don't make that decision for them.

and yet the Go maintainers did not include or build (in the future) a tool that determined the minimum version of Go that your application can be compiled in.

Re: Stop picking my Go version for me

#25

>My package really does depend on the latest patch release! > Even in the event that your packages code is only correct with a specific patch release, I still think its wrong to put that version in the go directive unless it cannot be compiled with any other version. I'm not a go user, but this strikes me as an over-reaction. If your code is only correct with a specific patch release, then it really is your business…

I can admit that part was maybe a bit extreme :) fortunately in practice this would be a pretty rare situation IME due to how compatible Go is across versions.

(Blog author)

Re: Stop picking my Go version for me

#26
post #18

Same situation in Rust crates, AIUI.

In go, `go mod init` and `go get go@latest` (both recommended commands), both set a 'go ' stanzas. In go, you _must_ set a minimum required version.

If you type 'cargo init', you will get 'edition = "2024"', but no 'rust-version'.

The situation is different because rust does not require a 'rust-version' in Cargo.toml, and in practice most crates do not have one, while in go it is required you specify a minimum version, there's no automation to set it to the true minimum, and most projects update it incorrectly in practice (because the go cli updates it incorrectly for you).

Re: Stop picking my Go version for me

#27
Or, I have only tested my library on this version, and nothing lower.

> Even in the event that your packages code is only correct with a specific patch release, I still think its not always right to put that version in the go directive unless it cannot be compiled with any other version.

This just makes me shiver. Imagine releasing a library with a version number slightly lower because of this post, it compiles, but there is a bug that brings down production...

Thanks but not thanks.

Re: Stop picking my Go version for me

#29

Weird that this needs to be said. I’m not familiar with the Go ecosystem, but there is usually a natural incentive for library developers to reach more people, which means you’d want to support the oldest feasible version. If you don’t do that then someone will develop a better library which does support an older version. Is that not happening here?

What the article does not say is that if you don't have a recent enough version, by default, Go automatically downloads a more recent toolchain. So, for most users, this is transparent.

However, this behavior can be disabled (for example, when building for a Linux distribution).

Re: Stop picking my Go version for me

#30

>It is not the version you use to compile your project But it is the version which they support. Pushing it back to an older version may result in bad behavior even if it does compile.

I think only languages which are still in beta have that kind of back compatibility. If a language breaks compatibility every two years (roughly Debian’s release schedule), it’s a toy, not a tool.

Go does not break compatibility every 2 years. I'm referring to Go fixing bugs in the language or standard runtime.
Post reply on HN