Skip to content

Makefile: add golangci-lint version check:#71

Merged
hao022 merged 1 commit intoccfos:mainfrom
huhong-web:main
Nov 25, 2025
Merged

Makefile: add golangci-lint version check:#71
hao022 merged 1 commit intoccfos:mainfrom
huhong-web:main

Conversation

@huhong-web
Copy link
Copy Markdown
Contributor

If the golangci-lint you are using was built with a Go version lower than the current project's code, golangci-lint will be stuck and use huge memory.

Makefile Outdated
-X main.AppVersion=$(APP_VERSION) \
-X main.AppGitCommit=$(APP_COMMIT) \
-X main.AppBuildTime=$(APP_BUILD_TIME)"
GO_VERSION := $(shell go version | awk '{print $$3}')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not use the below cmd
go env GOVERSION

@huhong-web
Copy link
Copy Markdown
Contributor Author

huhong-web commented Nov 24, 2025 via email

Makefile Outdated

which golangci-lint >/dev/null || \
{ echo "golangci-lint not found: $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; exit 1; }
@lint_go_version=$$(golangci-lint version --format json | cut -d'"' -f4); \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

jq need extra installation, so use cut.

Makefile Outdated
which golangci-lint >/dev/null || \
{ echo "golangci-lint not found: $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; exit 1; }
@lint_go_version=$$(golangci-lint version --format json | cut -d'"' -f4); \
older=$$(printf "%s\n%s" "$$lint_go_version" "$(GO_VERSION)" | sort -V | head -1); \
Copy link
Copy Markdown
Contributor Author

@huhong-web huhong-web Nov 24, 2025

Choose a reason for hiding this comment

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

In some case, e.g, comparing 1.11 and 1.9, need to do extra process.

…ersion used to

           build golangci-lint matches the Go version of the current project.
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.

2 participants