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:
Aliaksandr Valialkin 2023-07-13 11:51:56 -07:00
parent 4f6dc25c71
commit 9ae5a49787
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -409,17 +409,7 @@ vet:
go vet ./lib/... go vet ./lib/...
go vet ./app/... go vet ./app/...
# Set variables by using target specific variables to avoid running git diff for each make execution check-all: fmt vet golangci-lint govulncheck
# 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
test: test:
go test ./lib/... ./app/... go test ./lib/... ./app/...
@ -484,9 +474,6 @@ install-govulncheck:
install-wwhrd: install-wwhrd:
which wwhrd || go install github.com/frapposelli/wwhrd@latest 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 check-licenses: install-wwhrd
wwhrd check -f .wwhrd.yml wwhrd check -f .wwhrd.yml