-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use go 1.22
to allow building with go1.18
#3432
base: master
Are you sure you want to change the base?
Conversation
ec0d110
to
0f58683
Compare
0f58683
to
ac966a0
Compare
@@ -43,6 +43,6 @@ for dir in $MOD_DIRS; do | |||
( | |||
cd "$dir" | |||
go generate ./... | |||
GOTOOLCHAIN="go1.22+auto" go mod tidy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3428 reverted to fix the error while running ./script/lint.sh
:
linting tools
validating openapi_operations.yaml
validating generated files
go: downloading go1.22 (linux/amd64)
go: invalid toolchain: go1.22 is a language version but not a toolchain version (go1.22.x)
failed validating generated files
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3432 +/- ##
==========================================
- Coverage 97.72% 92.26% -5.46%
==========================================
Files 153 174 +21
Lines 13390 15023 +1633
==========================================
+ Hits 13085 13861 +776
- Misses 215 1068 +853
- Partials 90 94 +4 ☔ View full report in Codecov by Sentry. |
@alexandear - my question with this PR is... with your changes, is this simple to maintain? We've had a lot of churn in the last few weeks with Go versioning where people coming late to the party were not involved in the original changes (I'm not talking about you) and now we seem to be back-peddling to make sure everyone is happy that has now spoken up. So what I really want to know is... either as a developer or as a maintainer, can I run the scripts under I've seen some very weird behavior in the last few weeks due to the Thoughts? |
ALSO: Is the README.md still correct about versioning and toolchains after this PR? |
@dnwe - please comment on this PR. |
@gmlewis whilst I understand the motivation behind the PR (the code can currently be compiled with older versions than 1.22) and have some sympathy for it, I don’t think we should accept the PR as maintaining support for 1.18 isn’t a goal going forward and isn’t something we’ll test or commit to. I think the current model of support N-1 and N major releases is the correct stance for the module |
OK, thank you for your input, @dnwe. I've got conflicting feelings and sympathize with both viewpoints. Throughout the years, we have attempted to keep this client library usable by the largest audience possible. It is true that someone can pin their usage to a past version of this client library, but the downside to that is that the GitHub v3 API keeps evolving. And while I personally don't understand why people are not using one of latest minor versions of Go itself, I also know that sometimes big corporate projects don't have the bandwidth allocated to bring the project into the modern era by updating their Go version. So if @willnorris, the original author of this client library, has time to comment, I would greatly appreciate any guidance Will can provide. |
I wasn't aware there was a meaningful difference between That said, as a general philosophical point, I'm in favor of not breaking older versions if we don't have to, even if the official support is only for N-1. Assuming the proposed change here doesn't have any other unforeseen adverse effects (and I can't imagine that it would), I'd be in favor of making this change. |
Thank you, @willnorris , I appreciate your feedback! I'll wait for @alexandear to answer my maintenance questions before proceeding. |
@stevehipwell - looking at #3423, you might wish to comment on this PR as well. |
wow, fascinating... I completely missed all of that in golang/go#62278, though I certainly do remember noticing the change in vet warnings some time last year. Even after reading that, I think I'm still of the same opinion. If go-github actually requires some behavior in a patch release of 1.22, then that's one thing. But assuming that it doesn't, using |
@willnorris the problem is that changing to 1.22 like in this PR is a hack rather than a maintainable stance that sort of works because go 1.18 doesn't know about toolchains (introduced in go 1.21) so only understands the old Before Go 1.21, Go treated the go line as an advisory requirement: if builds succeeded the toolchain assumed everything worked, and if not it printed a note about the potential version mismatch. That's why changing to 1.22 happens to allow 1.18 to compile again. Go 1.21 changed the go line to be a mandatory requirement instead. This behaviour is partly backported to earlier language versions: Go 1.19 releases starting at Go 1.19.13 and Go 1.20 releases starting at Go 1.20.8 will refuse to load workspaces or modules declaring version Go 1.22 or later in the same way as newer releases.
It's complicated, but
So I don't think it would really be a desirable solution here either.
If you really wanted to maintain support for 1.18 then the correct solution would be to change the go.mod to have a go directive of 1.18 and to have GitHub actions' build matrix test using that to maintain the compatibility |
@gmlewis I'll have a refresher on the finer details around the Go tooling tomorrow before I comment on specifics. But as a general rule I'd advocate for the principal of least astonishment. |
I actually thought we might have had that, but don't see it now. I actually do that in other projects I maintain... keeping a matix test for the lower working version, even if it's not actually a supported version. For example: https://github.com/willnorris/imageproxy/blob/main/.github/workflows/tests.yml#L22-L26 (although somewhat ironically, that is also using a |
Do we know if tools like CodeQL and others updated to reflect the change of heart from the Go team in how the go directive is interpreted? From reading through the go issue, it sounds like the desire and intention is for the |
Yes from Go 1.23 onward they aliased I did raise it on the CodeQL issue tracker over here though |
Note: they didn't have a change of heart about treating the |
Right, I think I get that. But that other key difference is that older go version will attempt to download |
No the older Go versions don’t download anything, they just parse the directive and then ignore it and build with the local toolchain. However, when you get to the minor version Go 1.19.13 suddenly it will start parsing it and also refusing to compile because it’s > 1.19 Only Go versions 1.21 and newer will download a compatible toolchain |
Yes, it should be simple. As an example, I can provide links to the Go repository itself, which defines
Also, On the other hand, the See golang/go#69095 for the reasons behind that. In conclusion, after reading all comments, I'm sticking to |
Given that this package isn't compatible with Go |
When
go.mod
usesgo 1.22.0
(with.0
), building withgo1.18
orgo1.19
fails.Before:
After:
Follows #3423