oxsecurity / megalinter

🦙 MegaLinter analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
https://megalinter.io
GNU Affero General Public License v3.0
1.8k stars 215 forks source link

golangci-lint linter fails, as my go.mod has 1.22, but Alpine 3.19 has 1.21 #3676

Closed rasa closed 1 week ago

rasa commented 1 week ago

When I try to run the golangci-lint linter, I get

level=error msg="Running error: context loading failed: failed to load packages: 
failed to load packages: failed to load with go/packages: err: exit status 1: stderr:
go: go.mod requires go >= 1.22.2 (running go 1.21.10; GOTOOLCHAIN=local)\n"

Unfortunately, I can't downgrade my go.mod file.

It seems Alpine 3.19 has go 1.21.10 per here. Alpine 3.20 has go 1.22.3 per here.

Is there any way around this issue, other than upgrading to Alpine 3.20?

echoix commented 1 week ago

Does the extra package channels make it possible to install newer packages on 3.19?

rasa commented 1 week ago

@echoix Yes, according to here, you can

echo "@community https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
apk add go@community

If I submit a PR implementing this change, would it be considered? Or is there a way to do this locally?

Alternatively, https://dl-cdn.alpinelinux.org/alpine/v3.20/community would work as well, but would need to be maintained.

echoix commented 1 week ago

Yes, on your image, with pre-commands, you can edit your image before actual starting to lint to adapt to your needs

rasa commented 1 week ago

Cool, I haven't played with precommands, but will give it a spin. Thx for the help