Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/fix: fails to run on modules whose go directive value is in "1.n.m" format introduced in Go 1.21.0 [1.22 backport] #68825

Closed
gopherbot opened this issue Aug 9, 2024 · 6 comments
Labels
CherryPickApproved Used during the release process for point releases
Milestone

Comments

@gopherbot
Copy link
Contributor

@kolyshkin requested issue #62584 to be considered for backport to the next 1.22 minor release.

@gopherbot Please backport to Go 1.22.

When I run go fix using Go 1.22.5, it complains:

invalid -go=go1.21.0
exit status 2

While go1.23rc2 fix works fine.

@kolyshkin

This comment was marked as resolved.

@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/603981 mentions this issue: [release-branch.go1.22] cmd/fix: support go versions with patch release

@dmitshur

This comment was marked as resolved.

kolyshkin added a commit to kolyshkin/buildah that referenced this issue Aug 10, 2024
This change is generated by `go1.23rc2 fix ./...`.

Had to use go1.23rc2, since all released go versions have a bug
preventing it from working with `go 1.22.0` in go.mod (opened
golang/go#68825,
golang/go#68824 for awareness).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@dmitshur dmitshur changed the title cmd/fix: invalid -go=go1.21.0 [1.22 backport] cmd/fix: fails to run on modules whose go directive value is in "1.n.m" format introduced in Go 1.21.0 [1.22 backport] Aug 14, 2024
@cagedmantis
Copy link
Contributor

@kolyshkin Can you provide the rationale for why this is an issue without a known workaround?

@kolyshkin
Copy link
Contributor

@kolyshkin Can you provide the rationale for why this is an issue without a known workaround?

This breaks go fix for some packages (those that have go 1.2x.y in go.mod, i.e. where go version has a patch number) that are otherwise entirely valid.

The only workarounds I can think of are:

  1. Edit go.mod to remove the patch number (something like sed -i -e 's/\(go 1\.2[0-9]\)\.[0-9][0-9]*/\1/' go.mod) for the duration of go fix run.
  2. Not to use go fix at all.

To me neither one looks like a decent way to solve this.

@cherrymui cherrymui added the CherryPickApproved Used during the release process for point releases label Aug 21, 2024
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Aug 21, 2024
gopherbot pushed a commit that referenced this issue Aug 21, 2024
Support go version with patch release(e.g. 1.21.0)
and release candidates(e.g. 1.21rc1)
when parsing the go version in the fix command
by using new "go/version" package.

For #62584.
Fixes #68825.

Change-Id: I0ec16137c7a396c68039d374c770c4021fb54b4e
GitHub-Last-Rev: 76bced5
GitHub-Pull-Request: #62586
Reviewed-on: https://go-review.googlesource.com/c/go/+/527342
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alex Bozhenko <alexbozhenko@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit 7fd62ba)
Reviewed-on: https://go-review.googlesource.com/c/go/+/603981
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
@gopherbot
Copy link
Contributor Author

Closed by merging CL 603981 (commit 676d610) to release-branch.go1.22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases
Projects
None yet
Development

No branches or pull requests

5 participants