From 750a8465f547e9f08a87612c75898d56b8ec1f88 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 17 Nov 2021 20:34:35 +0800 Subject: A better go code formatter, and now `make fmt` can run in Windows (#17684) * go build / format tools * re-format imports --- Makefile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ecd91680ee..eea9f7ad53 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,6 @@ else SED_INPLACE := sed -i '' endif -GOFMT ?= gofmt -s - EXTRA_GOFLAGS ?= MAKE_VERSION := $(shell $(MAKE) -v | head -n 1) @@ -127,8 +125,6 @@ ifeq ($(filter $(TAGS_SPLIT),bindata),bindata) GO_SOURCES += $(BINDATA_DEST) endif -GO_SOURCES_OWN := $(filter-out vendor/% %/bindata.go, $(GO_SOURCES)) - #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger SWAGGER := $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger SWAGGER_SPEC := templates/swagger/v1_json.tmpl @@ -238,7 +234,7 @@ clean: .PHONY: fmt fmt: @echo "Running go fmt..." - @$(GOFMT) -w $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go gitea-fmt -s -w '{file-list}' .PHONY: vet vet: @@ -298,7 +294,7 @@ misspell-check: $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ fi @echo "Running misspell-check..." - @misspell -error -i unknwon $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go misspell -error -i unknwon '{file-list}' .PHONY: misspell misspell: @@ -306,12 +302,12 @@ misspell: $(GO) install github.com/client9/misspell/cmd/misspell@v0.3.4; \ fi @echo "Running go misspell..." - @misspell -w -i unknwon $(GO_SOURCES_OWN) + @$(GO) run build/code-batch-process.go misspell -w -i unknwon '{file-list}' .PHONY: fmt-check fmt-check: # get all go files and run go fmt on them - @diff=$$($(GOFMT) -d $(GO_SOURCES_OWN)); \ + @diff=$$($(GO) run build/code-batch-process.go gitea-fmt -s -d '{file-list}'); \ if [ -n "$$diff" ]; then \ echo "Please run 'make fmt' and commit the result:"; \ echo "$${diff}"; \ -- cgit v1.2.3