golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.8k stars 17.51k forks source link

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 closed 2 weeks ago

gopherbot commented 1 month ago

@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 commented 1 month ago

I tried to cherry-pick CL 527342 to release-branch.go1.22 via gerrit, and got this error:

An error occurred
Could not perform action: invalid author:
  email address alexbozhenko@gmail.com is not registered in your account, and you lack 'forge author' permission.
The following addresses are currently registered:
   kir@openvz.org
   kir@parallels.com
   kir@sacred.ru
   kolyshkin@gmail.com
To register an email address, visit:
https://go-review.googlesource.com/settings#EmailAddresses

I then tried do the same from the command line and got a similar error upon using git codereview mail HEAD.

Yet, I've tested it locally that the backport fixes the issue.

gopherbot commented 1 month ago

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

dmitshur commented 1 month ago

That limitation is mentioned at https://go.dev/wiki/MinorReleases#making-cherry-pick-cls (first sentence).

Thanks for testing it out locally.

cagedmantis commented 3 weeks ago

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

kolyshkin commented 3 weeks ago

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

gopherbot commented 2 weeks ago

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