From 9ae5a49787058a8eaf9f80a9579ec482142a83fd Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 13 Jul 2023 11:51:56 -0700 Subject: [PATCH] Revert "make: add goimports task (#4582)" This reverts commit 20b18e9feb71e91b3075bba74b245e5b35a4e5c8. 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. --- Makefile | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8a24846df..45ecabafc 100644 --- a/Makefile +++ b/Makefile @@ -409,17 +409,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/... @@ -484,9 +474,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