Skip to content

Commit

Permalink
go 1.17 has deprecated installing executables with go get
Browse files Browse the repository at this point in the history
Use go install instead
Set GOFLAGS to empty string to overcome the `cannot query module due to
-mod=vendor` error we get in presubmit job
  • Loading branch information
eranco74 committed Sep 19, 2022
1 parent e6fa01e commit 8594d8e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ envtest: ## Download envtest-setup locally if necessary.

MOCKGEN = $(shell pwd)/bin/mockgen
mockgen: ## Download mockgen locally if necessary.
$(call go-get-tool,$(MOCKGEN),github.com/golang/mock/mockgen)
$(call go-get-tool,$(MOCKGEN),github.com/golang/mock/mockgen@latest)

GOLINT = $(shell pwd)/bin/golangci-lint
golint: ## Download golangci-lint locally if necessary.
Expand All @@ -172,12 +172,8 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
rm -rf $$TMP_DIR ;\
echo "Installing $(2)" ;\
GOFLAGS="" GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
}
endef

Expand Down

0 comments on commit 8594d8e

Please sign in to comment.