Skip to content

build: use a zero for third digit for major release, such as 'go1.21.0' #57631

Closed
@thepudds

Description

@thepudds

Summary

#32450 and #27255 proposed adopting semantic versioning for Go releases. semver has a very specific definition, which means fully adopting it has significant challenges, including it raises certain expectations that don't apply, there are differences between what the go project vs. semver considered a "major release", and other sample problems mentioned here or here. Personally, I don't think it would be worthwhile to adopt semver for Go releases.

This is intentionally a narrower proposal, which is just to start adding the .0 to major releases at some point, such as go1.23.0.

Rationale 1: Stop old releases from using code they don't understand

Part of the context for this proposal is the auto-upgrading forward compatibility proposal (#57001), which would be a transition point for how Go versions overall are managed, and the related possible transition in the semantics of loop variables (#56010).

In #57001 (comment), Russ wrote (responding to @rittneje):

As an example, one of our teams tends to end up on officially unsupported versions because qualifying new releases is a large effort and doing it every six months is not feasible. It would be better if an explicit failure could be induced in older compilers (e.g., by adding a new directive to go.mod) instead of just assuming no one would use one.

For exactly the same kind of backwards compatibility, unrecognized lines in dependency go.mod files are ignored. So we've painted ourselves into a bit of a corner where the best we can do is prepare K versions that recognize that they don't understand the new code and then issue the K+1'th version supporting the new code. The only thing we really have control over is the choice of K. In the quoted text I was assuming K=1. Maybe we should do K=2, but I wouldn't want to do more than that and I'm not even sure K=2 is worth it.

Older go versions I think stretching back to go1.14 will reject a go.mod if the go line has a go version with a third digit, so always using three digits in the go.mod could be a way to cause even very old versions of cmd/go to fail if for example #56010 is adopted.

The majority of gophers would get the good behavior described in #57001 because most gophers would land within that K=1 or K=2 window, but this would be a broader enforcement mechanism that handles old Go releases outside that K window.

Example error (playground link):

go: errors parsing go.mod:
go.mod:3: invalid go version '1.25.0': must match format 1.23

In other words:

  • "enforcement & good errors" for most gophers
  • "enforcement & subotimal but google-able error" for much smaller subset of gophers using versions outside that K window

...which might be better than "unexpected semantics & no error" for that subset of gophers.

Rationale 2: Current source of confusion

I think releases like go1.20 have been a source of confusion, including when gophers are talking to each other about what version they are currently running or should run. Some older comments in a similar spirit:

@mvdan wrote in #29984:

I too have wished for 1.11 to be 1.11.0 for a while. Too many users think they're running the latest 1.11 because they're on 1.11. "What do you mean the latest 1.11? I am on 1.11"

@bcmills wrote in #29984:

Personally, I think it's pretty confusing to have the first patch version in the 1.11 line be named go1.11 rather than go1.11.0. [...] The lack of minor-version on the first release buries a major clue to the user that there might be more recent versions available. I would like to see us release Go 1.12 as go1.12.0 instead of go1.12.

Some costs

  1. Code or scripts that parse go versions would need to be updated or at least visited to ensure they handle the new format.

    • (In some cases, code that knows how to parse go1.23.1 might already handle go1.23.0).
    • (Also, any such code or scripts that is looking at go.mod already would need to be updated to handle the three digits for patch releases in go.mod proposed in #57001).
  2. Documentation, blogs, books, and so on would also need to be updated or be slightly stale.

    • (However, the impact of being stale or the work to update for a third digit might be small compared to the impact of #57001 overall).

In general, using a transition point to introduce even more change is a terrible idea in some cases. In other cases, it can be helpful to piggyback a desirable change on top of another transition. That said, I'm not sure which of those cases this proposal is. ;-)

Alternative

An alternative form of this proposal might be to just use zero in the third digit in go.mod and nowhere else, which might be a smaller change, but that then might be a ~mild source of confusion if it is inconsistent with other go version uses.

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions