@@ -61,7 +61,8 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
6161SKIP_GOLANGCI_LINT :=
6262GOLANGCI_LINT :=
6363GOLANGCI_LINT_OPTS ?=
64- GOLANGCI_LINT_VERSION ?= v1.64.6
64+ GOLANGCI_LINT_VERSION ?= v2.4.0
65+ GOLANGCI_FMT_OPTS ?=
6566# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
6667# windows isn't included here because of the path separator being different.
6768ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -138,7 +139,7 @@ common-deps:
138139update-go-deps:
139140 @echo ">> updating Go dependencies"
140141 @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
141- $(GO) get -d $$m; \
142+ $(GO) get $$m; \
142143 done
143144 $(GO) mod tidy
144145
@@ -156,9 +157,13 @@ $(GOTEST_DIR):
156157 @mkdir -p $@
157158
158159.PHONY: common-format
159- common-format:
160+ common-format: $(GOLANGCI_LINT)
160161 @echo ">> formatting code"
161162 $(GO) fmt $(pkgs)
163+ ifdef GOLANGCI_LINT
164+ @echo ">> formatting code with golangci-lint"
165+ $(GOLANGCI_LINT) fmt $(GOLANGCI_FMT_OPTS)
166+ endif
162167
163168.PHONY: common-vet
164169common-vet:
@@ -248,8 +253,8 @@ $(PROMU):
248253 cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
249254 rm -r $(PROMU_TMP)
250255
251- .PHONY: proto
252- proto:
256+ .PHONY: common- proto
257+ common- proto:
253258 @echo ">> generating code from proto files"
254259 @./scripts/genproto.sh
255260
@@ -261,6 +266,10 @@ $(GOLANGCI_LINT):
261266 | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
262267endif
263268
269+ .PHONY: common-print-golangci-lint-version
270+ common-print-golangci-lint-version:
271+ @echo $(GOLANGCI_LINT_VERSION)
272+
264273.PHONY: precheck
265274precheck::
266275
0 commit comments