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

Set GO111MODULE to auto in golint script– #1743 #1744

Merged
merged 3 commits into from Dec 10, 2021

Conversation

rbrtl
Copy link
Contributor

@rbrtl rbrtl commented Dec 9, 2021

As mentioned in #1743 the Go modules environment flag is set to off
in the script which appears to cause a warning message for each module
of the codebase that it is "not in GOROOT".

Set to auto as this allows the same build to be run the original way
should someone choose to delete the go.mod file from the project root.

What is the problem I am trying to address?

Golint warning for each submodule of Athens "package not in GOROOT" when running Make target verify

How is the fix applied?

Set GO111MODULE=auto in ./scripts/check_golint.sh

What GitHub issue(s) does this PR fix or close?

Fixes #1743

As mentioned in gomods#1743 the Go modules environment flag is set to `off`
in the script which appears to cause a warning message for each module
of the codebase that it is "not in GOROOT".

Set to `auto` as this allows the same build to be run the original way
should someone choose to delete the `go.mod` file from the project root.
@rbrtl rbrtl requested a review from a team as a code owner December 9, 2021 16:16
@@ -4,4 +4,4 @@
# Run the linter on everything except generated code
set -euo pipefail

golint -set_exit_status $(GO111MODULE=off go list ./... | grep -v '/mocks')
golint -set_exit_status $(GO111MODULE=auto go list ./... | grep -v '/mocks')
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this change. I believe we have now started to build for go1.17.

Go1.17 will ignore this flag: https://go.dev/blog/go116-module-changes.
I believe: #815 was an explicit choice though to make the CI faster

I am not sure if this will work anymore. Maybe we should just remove it: cc @marwan-at-work ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think it's worth removing. Also, do we even have /mock? I wonder if we can do golinst ./... or golint go list ./...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do it right and raise another PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked golint ./... vs. golint $(go list ./...)... I am struggling to prove it definitively prove that the former is linting all the files covered by the latter. The go list subshell command version takes noticeably longer, but that's not to say, necessarily, that the golint command isn't examining all the correct files. Any input on that much appreciated.

Copy link
Member

@manugupt1 manugupt1 Dec 10, 2021

Choose a reason for hiding this comment

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

Thank you for doing it right. I just noticed that even golint is deprecated.
https://github.com/golang/lint
Would you be able to update the code to use staticcheck and go vet?

We already use govet

- go vet ./...

I would probably just start with govet, open an issue and then do a separate PR for staticcheck. I hope this helps.

Go 1.17 ignores `GO111MODULE` and there are no directories in the
project root called `mock`.
`golint` is deprecated (and frozen) replace with the current `go vet`.
This reported one issue on `main` branch:
```pkg/stash/with_etcd.go:33:28:
loop variable ep captured by func literal```

Fixed loop variable capture with extraction to parameterised anonymous
function passed loop variable and passed in to `errgroup.Go` call.
@rbrtl
Copy link
Contributor Author

rbrtl commented Dec 10, 2021

Thanks @manugupt1 I have made the change to go vet for this, and I think leaving staticcheck for another ticket is a good plan; it threw up a lot more lint than go vet. Happy to open another issue for that and take a look at sorting those out too.

@manugupt1
Copy link
Member

Thanks for making this change. Also congrats on your first PR 🎉

@manugupt1 manugupt1 self-requested a review December 10, 2021 04:57
@manugupt1 manugupt1 merged commit 918ddfb into gomods:main Dec 10, 2021
@rbrtl rbrtl mentioned this pull request Dec 11, 2021
@arschles
Copy link
Member

@rbrtl this is awesome - thank you!

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.

golint checks in make verify throw GOROOT error
4 participants