mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 22:27:17 +02:00
Add golangci-lint fmt (#16602)
With golangci-lint v2, it now has "formatters" that can be configured. Add `golangci-lint fmt` to the `make format` in Makefile.common. * Enable goimports formatter. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
3eb44003c6
commit
1eaf12e99b
@ -2,6 +2,7 @@ formatters:
|
|||||||
enable:
|
enable:
|
||||||
- gci
|
- gci
|
||||||
- gofumpt
|
- gofumpt
|
||||||
|
- goimports
|
||||||
settings:
|
settings:
|
||||||
gci:
|
gci:
|
||||||
sections:
|
sections:
|
||||||
@ -10,6 +11,9 @@ formatters:
|
|||||||
- prefix(github.com/prometheus/prometheus)
|
- prefix(github.com/prometheus/prometheus)
|
||||||
gofumpt:
|
gofumpt:
|
||||||
extra-rules: true
|
extra-rules: true
|
||||||
|
goimports:
|
||||||
|
local-prefixes:
|
||||||
|
- github.com/prometheus/prometheus
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
|
@ -62,6 +62,7 @@ SKIP_GOLANGCI_LINT :=
|
|||||||
GOLANGCI_LINT :=
|
GOLANGCI_LINT :=
|
||||||
GOLANGCI_LINT_OPTS ?=
|
GOLANGCI_LINT_OPTS ?=
|
||||||
GOLANGCI_LINT_VERSION ?= v2.1.5
|
GOLANGCI_LINT_VERSION ?= v2.1.5
|
||||||
|
GOLANGCI_FMT_OPTS ?=
|
||||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
|
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
|
||||||
# windows isn't included here because of the path separator being different.
|
# windows isn't included here because of the path separator being different.
|
||||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
||||||
@ -156,9 +157,13 @@ $(GOTEST_DIR):
|
|||||||
@mkdir -p $@
|
@mkdir -p $@
|
||||||
|
|
||||||
.PHONY: common-format
|
.PHONY: common-format
|
||||||
common-format:
|
common-format: $(GOLANGCI_LINT)
|
||||||
@echo ">> formatting code"
|
@echo ">> formatting code"
|
||||||
$(GO) fmt $(pkgs)
|
$(GO) fmt $(pkgs)
|
||||||
|
ifdef GOLANGCI_LINT
|
||||||
|
@echo ">> formatting code with golangci-lint"
|
||||||
|
$(GOLANGCI_LINT) fmt $(GOLANGCI_FMT_OPTS)
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: common-vet
|
.PHONY: common-vet
|
||||||
common-vet:
|
common-vet:
|
||||||
|
@ -39,8 +39,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
// Required to get the GCP auth provider working.
|
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // Required to get the GCP auth provider working.
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
Loading…
Reference in New Issue
Block a user