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

goLint: add a check that go.mod is tidied #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marten-seemann
Copy link

Name of feature:

Check that go.mod is tidied.

Pain or issue this feature alleviates:

There's no reason to commit a go.mod that is not tidied.

Why is this important to the project (if not answered above):

Best case an untidy go.mod pulls in dependencies that are not needed, worst case it leads to build failures due to incorrect module hashes.

Is there documentation on how to use this feature? If so, where?

https://go.dev/ref/mod#go-mod-tidy

In what environments or workflows is this feature supported?

All of them.

In what environments or workflows is this feature explicitly NOT supported (if any)?

None.

Supporting links/other PRs/issues:

I've been running this logic in quic-go for a long time.

💔Thank you!

@marten-seemann marten-seemann requested a review from a team as a code owner June 29, 2024 04:29
@CLAassistant
Copy link

CLAassistant commented Jun 29, 2024

CLA assistant check
All committers have signed the CLA.

@marten-seemann marten-seemann enabled auto-merge (squash) July 3, 2024 02:45
@dopey
Copy link
Contributor

dopey commented Jul 8, 2024

I'm actually worried about this one because recently go mod tidy has been adding gotoolchain to all our go.mod files, as well as modifying the selected version to be of the format x.y.z, rather than x.y (which is what we currently use). We should probably agree to this change as a team before merging, as this check may start failing for a large proportion of our repos.

Copy link
Contributor

@dopey dopey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worried that this may cause linting errors for most of our repos.

@marten-seemann
Copy link
Author

marten-seemann commented Jul 8, 2024

as well as modifying the selected version to be of the format x.y.z, rather than x.y (which is what we currently use).

I don't think that's a valid value for >= Go 1.21. This is because they recently changed the naming of the initial Go releases. The documentation states:

The standard Go toolchains are named goV where V is a Go version denoting a beta release, release candidate, or release. For example, go1.21rc1 and go1.21.0 are toolchain names; go1.21 and go1.22 are not (the initial releases are go1.21.0 and go1.22.0), but go1.20 and go1.19 are.


I'm actually worried about this one because recently go mod tidy has been adding gotoolchain to all our go.mod files

It shouldn't add a gotoolchain if none is present (I've been running it in quic-go for years, it never once added a toolchain line).


Worried that this may cause linting errors for most of our repos.

I ran go mod tidy for the following repos:

  • agent
  • autocert
  • bouncer
  • certificates
  • cli
  • cli-utils
  • crypto
  • guardian
  • inventory
  • step-issuer

In none of these repos did it introduce any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants