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

Update golangci-lint for go 1.20 #241

Closed

Conversation

marckhouzam
Copy link
Contributor

@marckhouzam marckhouzam commented Apr 30, 2023

This PR is on top of #243 because CI was failing

What this PR does / why we need it

This PR update golangci-lint to version 1.52.2 for it to work with go 1.20

Note that "allow-leading-space" is no longer supported as mentioned in golangci/golangci-lint#3063 (comment)

The PR fixes or disables (appropriately) new warnings that are now reported.

This has been done in the sister repo: vmware-tanzu/tanzu-plugin-runtime#56

Which issue(s) this PR fixes

Fixes #240

Describe testing done for PR

Ran make go-lint with the new version of golangci-lint using both go 1.19 and go 1.20, which are the only two versions we support for the tanzu-cli repo.

$ rm hack/tools/bin/golangci-lint
$ asdf shell golang 1.19.4 ;go version;make go-lint
go version go1.19.4 darwin/arm64
make -C /Users/kmarc/git/tanzu-cli/hack/tools golangci-lint
mkdir -p bin
GOBIN=/Users/kmarc/git/tanzu-cli/hack/tools/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
/Users/kmarc/git/tanzu-cli/hack/tools/bin/golangci-lint run --timeout=10m || exit 1
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [linters_context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.
# Prevent use of deprecated ioutils module
$

$ asdf shell golang 1.20.3;go version;make go-lint
go version go1.20.3 darwin/arm64
make -C /Users/kmarc/git/tanzu-cli/hack/tools golangci-lint
make[1]: Nothing to be done for `golangci-lint'.
/Users/kmarc/git/tanzu-cli/hack/tools/bin/golangci-lint run --timeout=10m || exit 1
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [linters_context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.
# Prevent use of deprecated ioutils module
$

Release note


Additional information

Special notes for your reviewer

This change was prompted that the makefiles generated for a new plugin project was also using golangci-lint v1.49.0 which would cause plugin projects not fail linting if they wanted to use go 1.20.

@marckhouzam marckhouzam requested a review from a team as a code owner April 30, 2023 21:05
@marckhouzam marckhouzam force-pushed the feat/updateGolangci branch 2 times, most recently from 902cb47 to fa2c943 Compare April 30, 2023 21:26
Fixes vmware-tanzu#240

Note that "allow-leading-space" is no longer supported as mentioned in
golangci/golangci-lint#3063 (comment)

Fix new warnings that are now reported.

Signed-off-by: Marc Khouzam <[email protected]>
@marckhouzam marckhouzam force-pushed the feat/updateGolangci branch from fa2c943 to a28c67f Compare May 1, 2023 12:37
@marckhouzam marckhouzam marked this pull request as draft May 1, 2023 13:24
@marckhouzam
Copy link
Contributor Author

I'm having a lot of error from revive, which will require more time.
Originally I had disabled a single error type from revive and thought everything was fine, but it turns out that revive was turned off completely. When trying to fix that, golangci-lint crashes. I'll get back to this when I have more time.

The problematic configuration is:

linters-settings:
  revive:
    # As soon as a config is provides, all rules are disabled
    # This enable-all-rules setting should turn them back on
    # But it crashes golangci-lint 1.52.2 (I tried it with go 1.20.3)
    enable-all-rules: true
    rules:
      - name: unused-parameter
        disabled: true

@marckhouzam
Copy link
Contributor Author

This has been done in another PR

@marckhouzam marckhouzam closed this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

golangci-lint fails with go 1.20
2 participants