Skip to content

Commit 9c11a36

Browse files
authored
Remove duplicate linters and use gci for imports (#9)
Signed-off-by: Anuraag Agrawal <[email protected]>
1 parent ed61ec6 commit 9c11a36

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

.golangci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ linters:
99
- exportloopref
1010
- importas
1111
- gci
12-
- gofmt
1312
- gofumpt
14-
- goimports
1513
- gocritic
1614
- gosec
1715
- govet
@@ -70,12 +68,6 @@ linters-settings:
7068
- default
7169
# Groups all imports with the specified Prefix.
7270
- prefix(github.com/envoyproxy/ai-gateway)
73-
gofmt:
74-
simplify: true
75-
goimports:
76-
# put imports beginning with prefix after 3rd-party packages;
77-
# it's a comma-separated list of prefixes
78-
local-prefixes: github.com/envoyproxy/ai-gateway
7971
govet:
8072
enable-all: true
8173
disable:

Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ lint: golangci-lint
77
@$(GOLANGCI_LINT) run --build-tags=$(LINT_BUILD_TAGS) ./...
88

99
.PHONY: format
10-
format: goimports gofumpt
10+
format: gci gofumpt
1111
@echo "format => *.go"
1212
@find . -type f -name '*.go' | xargs gofmt -s -w
1313
@find . -type f -name '*.go' | xargs $(GO_FUMPT) -l -w
14-
@echo "goimports => *.go"
15-
@for f in `find . -name '*.go'`; do \
16-
awk '/^import \($$/,/^\)$$/{if($$0=="")next}{print}' $$f > /tmp/fmt; \
17-
mv /tmp/fmt $$f; \
18-
done
19-
@$(GO_IMPORTS) -w -local github.com/envoyproxy/ai-gateway `find . -name '*.go'`
14+
@echo "gci => *.go"
15+
@$(GCI) write -s standard -s default -s "prefix(github.com/envoyproxy/ai-gateway)" `find . -name '*.go'`
2016

2117
.PHONY: tidy
2218
tidy: ## Runs go mod tidy on every module

Makefile.tools.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ $(LOCALBIN):
55
## Tool binary names.
66
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
77
GO_FUMPT = $(LOCALBIN)/gofumpt
8-
GO_IMPORTS = $(LOCALBIN)/goimports
8+
GCI = $(LOCALBIN)/gci
99

1010
## Tool versions.
1111
GOLANGCI_LINT_VERSION ?= v1.60.1
1212
GO_FUMPT_VERSION ?= v0.6.0
13-
GO_IMPORTS_VERSION ?= v0.21.0
13+
GCI_VERSION ?= v0.13.5
1414

1515
.PHONY: golangci-lint
1616
golangci-lint: $(GOLANGCI_LINT)
@@ -22,10 +22,10 @@ gofumpt: $(GO_FUMPT)
2222
$(GO_FUMPT): $(LOCALBIN)
2323
$(call go-install-tool,$(GO_FUMPT),mvdan.cc/gofumpt,$(GO_FUMPT_VERSION))
2424

25-
.PHONY: goimports
26-
goimports: $(GO_IMPORTS)
27-
$(GO_IMPORTS): $(LOCALBIN)
28-
$(call go-install-tool,$(GO_IMPORTS),golang.org/x/tools/cmd/goimports,$(GO_IMPORTS_VERSION))
25+
.PHONY: gci
26+
gci: $(GCI)
27+
$(GCI): $(LOCALBIN)
28+
$(call go-install-tool,$(GCI),github.com/daixiang0/gci,$(GCI_VERSION))
2929

3030
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
3131
# $1 - target path with name of binary

0 commit comments

Comments
 (0)