diff options
author | Adrian Villin <avillin@cisco.com> | 2024-09-26 11:24:34 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-09-28 02:11:59 +0000 |
commit | 5a4c7a9ce4162f8f9fb397d6b9b59e7fe59beeea (patch) | |
tree | 60e2e47b271a85200eef2b483a9a5593b8a6ef22 /extras/hs-test/Makefile | |
parent | 6f173171b1d5c4b10165a7d8603e4e6b9d07b7b4 (diff) |
hs-test: replaced gofmt with goimports
- goimports properly formats imports
Type: test
Change-Id: I78c162dd552fd3ee3d59955d7ea215af30601425
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/Makefile')
-rw-r--r-- | extras/hs-test/Makefile | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 2a501580e53..b72aca1d7dd 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -184,10 +184,19 @@ install-deps: @apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin @touch .deps.ok +.goimports.ok: + @rm -f .goimports.ok + go install golang.org/x/tools/cmd/goimports@v0.25.0 + @touch .goimports.ok + .PHONY: checkstyle-go -checkstyle-go: - @output=$$(gofmt -d $${WS_ROOT}); \ - if [ -z "$$output" ]; then \ +checkstyle-go: .goimports.ok + $(eval GOPATH := $(shell go env GOPATH)) + @output=$$($(GOPATH)/bin/goimports -d $${WS_ROOT}); \ + status=$$?; \ + if [ $$status -ne 0 ]; then \ + exit $$status; \ + elif [ -z "$$output" ]; then \ echo "*******************************************************************"; \ echo "Checkstyle OK."; \ echo "*******************************************************************"; \ @@ -200,9 +209,10 @@ checkstyle-go: fi .PHONY: fixstyle-go -fixstyle-go: +fixstyle-go: .goimports.ok + $(eval GOPATH := $(shell go env GOPATH)) @echo "Modified files:" - @gofmt -w -l $(WS_ROOT) + @$(GOPATH)/bin/goimports -w -l $(WS_ROOT) @go mod tidy @echo "*******************************************************************" @echo "Fixstyle done." |