Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: goimports failed in make all #583

Merged
merged 6 commits into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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