diff --git a/Makefile b/Makefile index 0b18ac402..dcef899cf 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,19 @@ PKG := github.com/lightningnetwork/lnd MOBILE_PKG := $(PKG)/mobile TOOLS_DIR := tools +TOOLS_MOD := $(TOOLS_DIR)/go.mod GOCC ?= go PREFIX ?= /usr/local +GOTOOL := GOWORK=off $(GOCC) tool -modfile=$(TOOLS_MOD) + + BTCD_PKG := github.com/btcsuite/btcd GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports GO_BIN := ${GOPATH}/bin BTCD_BIN := $(GO_BIN)/btcd -GOIMPORTS_BIN := $(GO_BIN)/gosimports GOMOBILE_BIN := $(GO_BIN)/gomobile MOBILE_BUILD_DIR :=${GOPATH}/src/$(MOBILE_PKG)/build @@ -88,10 +91,6 @@ $(BTCD_BIN): @$(call print, "Installing btcd.") cd $(TOOLS_DIR); $(GOCC) install -trimpath $(BTCD_PKG) -$(GOIMPORTS_BIN): - @$(call print, "Installing goimports.") - cd $(TOOLS_DIR); $(GOCC) install -trimpath $(GOIMPORTS_PKG) - # ============ # INSTALLATION # ============ @@ -315,9 +314,9 @@ fuzz: # ========= #? fmt: Format source code and fix imports -fmt: $(GOIMPORTS_BIN) +fmt: @$(call print, "Fixing imports.") - gosimports -w $(GOFILES_NOVENDOR) + $(GOTOOL) $(GOIMPORTS_PKG) -w $(GOFILES_NOVENDOR) @$(call print, "Formatting source.") gofmt -l -w -s $(GOFILES_NOVENDOR) diff --git a/tools/go.mod b/tools/go.mod index e0dd6350e..e97047cc7 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -232,5 +232,5 @@ tool ( // Once golangci-lint v2.4.1 update it here. // Also don't forget to update the .custom-gcl.yml file. github.com/golangci/golangci-lint/v2/cmd/golangci-lint - github.com/rinchsan/gosimports + github.com/rinchsan/gosimports/cmd/gosimports )