From e09d10f84fb7853e221e7003ecb07e30503142b4 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 18 Oct 2021 12:32:16 +0530 Subject: [PATCH 1/2] Makefile: add golangci-lint target This target will download the specified version of golangci-lint binary in case it is not available. --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 46e46ab0..da0337c7 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ GOPATH ?= $(shell go env GOPATH) BINARY_NAME := crc-admin-helper RELEASE_DIR ?= release +GOLANGCI_LINT_VERSION = v1.41.1 LDFLAGS := -X github.com/code-ready/admin-helper/pkg/constants.Version=$(VERSION) -extldflags='-static' -s -w $(GO_LDFLAGS) @@ -27,6 +28,12 @@ clean: rm -fr release rm -fr crc-admin-helper.spec +.PHONY: golangci-lint +golangci-lint: + @if $(GOPATH)/bin/golangci-lint version 2>&1 | grep -vq $(GOLANGCI_LINT_VERSION); then\ + pushd /tmp && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) && popd; \ + fi + $(BUILD_DIR)/macos-amd64/$(BINARY_NAME): CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/macos-amd64/$(BINARY_NAME) $(GO_BUILDFLAGS) ./cmd/admin-helper/ @@ -52,8 +59,8 @@ build: CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o $(BINARY_NAME) $(GO_BUILDFLAGS) ./cmd/admin-helper/ .PHONY: lint -lint: - golangci-lint run +lint: golangci-lint + $(GOPATH)/bin/golangci-lint run .PHONY: test test: From 62888007cbca715ac59718948e38d66c5c0d0541 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 18 Oct 2021 12:34:49 +0530 Subject: [PATCH 2/2] golangci-lint: replace golint with revive This patch fixes following warning ``` WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive. ``` --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index abdbf3ea..8f661583 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,4 +10,4 @@ linters: - gocritic - deadcode - misspell - - golint + - revive