Skip to content

Commit

Permalink
fix: goimports failed in make all (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
rayowang authored May 20, 2022
1 parent e1a0b55 commit 3565211
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions make/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,35 @@ go.style:
go.format.verify:
ifeq ($(shell which goimports), )
@echo "===========> Installing missing goimports"
@GO111MODULE=off $(GO) get -u golang.org/x/tools/cmd/goimports
@mkdir -p $(GOPATH)/src/github.com/golang
@mkdir -p $(GOPATH)/src/golang.org/x
ifeq ($(shell if [ -d $(GOPATH)/src/github.com/golang/tools ]; then echo "exist"; else echo ""; fi;), )
@git clone https://github.com/golang/tools.git $(GOPATH)/src/github.com/golang/tools
endif
ifeq ($(shell if [ -d $(GOPATH)/src/golang.org/x/tools ]; then echo "exist"; else echo ""; fi;), )
@ln -s $(GOPATH)/src/github.com/golang/tools $(GOPATH)/src/golang.org/x/tools
endif

ifeq ($(shell if [ -d $(GOPATH)/src/github.com/golang/mod ]; then echo "exist"; else echo ""; fi;), )
@git clone https://github.com/golang/mod.git $(GOPATH)/src/github.com/golang/mod
endif
ifeq ($(shell if [ -d $(GOPATH)/src/golang.org/x/mod ]; then echo "exist"; else echo ""; fi;), )
@ln -s $(GOPATH)/src/github.com/golang/mod $(GOPATH)/src/golang.org/x/mod
endif

ifeq ($(shell if [ -d $(GOPATH)/src/github.com/golang/sys ]; then echo "exist"; else echo ""; fi;), )
@git clone https://github.com/golang/sys.git $(GOPATH)/src/github.com/golang/sys
endif
ifeq ($(shell if [ -d $(GOPATH)/src/golang.org/x/sys ]; then echo "exist"; else echo ""; fi;), )
@ln -s $(GOPATH)/src/github.com/golang/sys $(GOPATH)/src/golang.org/x/sys
endif
@GO111MODULE=off $(GO) build $(GOPATH)/src/golang.org/x/tools/cmd/goimports
@GO111MODULE=off $(GO) install $(GOPATH)/src/golang.org/x/tools/cmd/goimports
endif

.PHONY: go.format
go.format: go.format.verify
@echo "===========> Running go codes format"
$(GO_FMT) -s -w .
$(GO_IMPORTS) -w -local $(GO_MODULE) .
$(GOPATH)/bin/$(GO_IMPORTS) -w -local $(GO_MODULE) .
$(GO) mod tidy

0 comments on commit 3565211

Please sign in to comment.