Skip to content

Conversation

hjoshi123
Copy link

@hjoshi123 hjoshi123 commented Jun 28, 2025

Fixes #27.

Added the following linters:

    - asasalint
    - asciicheck
    - bidichk
    - bodyclose
    - canonicalheader
    - contextcheck
    - copyloopvar
    - decorder
    - dogsled
    - dupword
    - durationcheck
    - errcheck
    - errchkjson
    - errname
    - exhaustive
    - exptostd
    - forbidigo
    - gocheckcompilerdirectives
    - gochecksumtype
    - gocritic
    - goheader
    - goprintffuncname
    - gosec
    - gosmopolitan
    - govet
    - grouper
    - importas
    - ineffassign
    - interfacebloat
    - intrange
    - loggercheck
    - makezero
    - mirror
    - misspell
    - musttag
    - nakedret
    - nilerr
    - nilnil
    - noctx
    - nosprintfhostport
    - predeclared
    - promlinter
    - protogetter
    - reassign
    - sloglint
    - staticcheck
    - tagalign
    - testableexamples
    - unconvert
    - unparam
    - unused
    - usestdlibvars
    - usetesting
    - wastedassign

@katiewasnothere
Copy link
Contributor

Hi @hjoshi123 thank you for the change! Was there a particular reason you chose this set of checks?

.golangci.yaml Outdated
gci:
sections:
- standard
- defaul
Copy link
Contributor

Choose a reason for hiding this comment

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

default

.golangci.yaml Outdated
- exhaustive
- exptostd
- forbidigo
- ginkgolinter
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need this. We don't have any ginkgo tests in this repo.

ci_install=true
fi
if [[ "$ci_install" == true ]]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/cc3567e3127d8530afb69be1b7bd20ba9ebcc7c1/install.sh \
Copy link
Contributor

Choose a reason for hiding this comment

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

In the other container project repos, we tend to install things under a .local directory for make to use (example https://github.com/apple/container/blob/9eb2f860fc35a933e7894bc5313e3b79cd001c52/Makefile#L162).

ci_install=true
fi
if [[ "$ci_install" == true ]]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/cc3567e3127d8530afb69be1b7bd20ba9ebcc7c1/install.sh \
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could do something like this for the address

https://raw.githubusercontent.com/golangci/golangci-lint/${GOLANGCI_LINTER_VERSION}/install.sh

Copy link
Author

Choose a reason for hiding this comment

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

Yup that makes sense.. changing it

@hjoshi123
Copy link
Author

hjoshi123 commented Jul 1, 2025

Hi @hjoshi123 thank you for the change! Was there a particular reason you chose this set of checks?

Some of them were mentioned by default in the golangci lint docs and then I referred some of the k8s repos for others. Will make changes to remove some of them which are irrelevant as you mentioned.

@katiewasnothere
Copy link
Contributor

@hjoshi123 Were you able to make the changes here?

@hjoshi123
Copy link
Author

@katiewasnothere sorry was busy with work.. will push the changes by this weekend.


.PHONY: go-lint
go-lint: golangci-lint-install
$(GOLANGCI_LINT) config verify
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will work when the script has installed golangci-lint under .local/bin. I think following something similar to what we do for installing protoc would be good. What do you think?


install_golangci() {
ci_install=false
if [[ -x $(which golangci-lint) ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I think which will not find the binary if it's installed under .local/bin

Comment on lines +22 to +25
if [[ "${version}" == "${GOLANGCI_LINTER_VERSION#v}" ]]; then
ci_install=false
else
ci_install=true
Copy link
Contributor

Choose a reason for hiding this comment

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

If we do something like how we install protoc, we get the check for whether to install golangci-lint for free since make will check if the file path exists, as it does for protoc here. Does that make sense?

- name: Check protobufs
run: |
- name: Verify linter configuration and Lint go code
uses: golangci/golangci-lint-action@v8
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should instead call the makefile command to install golangci-lint and then run it. That way the behavior is the same between local dev and the CI run.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the CI right now won't run for this PR right now since golangci/golangci-lint-action@v8 is not in our allowlist for actions that can be run

@katiewasnothere
Copy link
Contributor

katiewasnothere commented Sep 22, 2025

Closing for now since there haven't been updates on this PR in the last month. Please feel free to reopen.

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.

[Request]: Setup and Use GolangCI Lint for the project

2 participants