mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-12 12:46:23 +01:00
Revert "make: add goimports task (#4582)"
This reverts commit 20b18e9feb
.
Reason for revert: running goimports on `make check-all` introduces the following issues:
- It runs only on modified files, which weren't commited yet into git repository.
This means the formatting for the remaining files becomes different comparing to the formatting
for the changed files. This also means that the goimports has no any effect
at github actions and when the changed code is already commited to git repository.
- `gomiports` performs formatting in the same way as gofmt, so `make fmt` becomes unnecessary.
But when `gofmt` is substituted with `goimports`, then it performs unnecessary formatting for *.qtpl.go files.
It is possible to make a hack, which will prepare a list of all the *.go files at lib/ and app/
without the *.qtpl.go files, and then feed this list to `goimports`, but this looks too fragile
for the task of just fixing the ordering of Go imports.
So it is better to leave source code formatting as is with `gofmt`, while manually fixing improper ordering
of Go import from time to time in dedicated commits until better solution arises.
This commit is contained in:
parent
64149782ac
commit
3e5e55d235
15
Makefile
15
Makefile
@ -170,17 +170,7 @@ vet:
|
||||
go vet ./lib/...
|
||||
go vet ./app/...
|
||||
|
||||
# Set variables by using target specific variables to avoid running git diff for each make execution
|
||||
# See: https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
|
||||
goimports: GO_CHANGED_FILES+=$(shell git diff --name-only --diff-filter=ACMR HEAD -- 'lib/*.go')
|
||||
goimports: GO_CHANGED_FILES+=$(shell git diff --name-only --diff-filter=ACMR HEAD -- 'app/*.go')
|
||||
goimports: install-goimports
|
||||
# GO_CHANGED_FILES will contain a single space if there are no changed files
|
||||
if [ "$(GO_CHANGED_FILES)" != " " ]; then \
|
||||
goimports -local github.com/VictoriaMetrics/VictoriaMetrics -w $(GO_CHANGED_FILES); \
|
||||
fi
|
||||
|
||||
check-all: fmt goimports vet golangci-lint govulncheck
|
||||
check-all: fmt vet golangci-lint govulncheck
|
||||
|
||||
test:
|
||||
go test ./lib/... ./app/...
|
||||
@ -245,9 +235,6 @@ install-govulncheck:
|
||||
install-wwhrd:
|
||||
which wwhrd || go install github.com/frapposelli/wwhrd@latest
|
||||
|
||||
install-goimports:
|
||||
which goimports || go install golang.org/x/tools/cmd/goimports@latest
|
||||
|
||||
check-licenses: install-wwhrd
|
||||
wwhrd check -f .wwhrd.yml
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user