From f5758afc4051ef1e3066300a658d4b1914305f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ota=CC=81vio=20Fernandes?= Date: Mon, 28 Oct 2019 11:01:00 +0100 Subject: [PATCH] chore(hack): Go Modules based scripts. --- Makefile | 2 +- hack/common.sh | 11 ++++------- hack/install-tools.sh | 2 +- hack/test-go.sh | 3 +-- hack/verify-deps.sh | 6 +++--- hack/verify-golint.sh | 2 +- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 4cbf1ec5d..d28972773 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ verify: build hack/verify-gofmt.sh hack/verify-golint.sh hack/verify-govet.sh - hack/verify-godeps.sh || true # remove this to make godepchecker's warnings actionable + hack/verify-deps.sh hack/verify-bash-completion.sh .PHONY: verify diff --git a/hack/common.sh b/hack/common.sh index c565cd241..54903e7c2 100755 --- a/hack/common.sh +++ b/hack/common.sh @@ -92,6 +92,7 @@ s2i::build::build_binaries() { CGO_ENABLED=0 go install "${goflags[@]:+${goflags[@]}}" \ -pkgdir "${S2I_OUTPUT_PKGDIR}" \ -ldflags "${version_ldflags} ${RELEASE_LDFLAGS}" \ + -mod vendor \ "${binaries[@]}" s2i::build::unset_platform_envs "${platform}" done @@ -175,7 +176,6 @@ s2i::build::create_gopath_tree() { # # Input Vars: # S2I_EXTRA_GOPATH - If set, this is included in created GOPATH -# S2I_NO_GODEPS - If set, we don't add 'vendor' to GOPATH # # Output Vars: # export GOPATH - A modified GOPATH to our created tree along with extra @@ -195,6 +195,9 @@ EOF exit 2 fi + # Enabling support for Go Modules. + export GO111MODULE=on + # For any tools that expect this to be set (it is default in golang 1.6), # force vendor experiment. export GO15VENDOREXPERIMENT=1 @@ -206,12 +209,6 @@ EOF GOPATH="${GOPATH}:${S2I_EXTRA_GOPATH}" fi - # Append the tree maintained by `godep` to the GOPATH unless S2I_NO_GODEPS - # is defined. - if [[ -z ${S2I_NO_GODEPS:-} ]]; then - GOPATH="${GOPATH}:${S2I_ROOT}/vendor" - fi - if [[ "$OSTYPE" == "cygwin" ]]; then GOPATH=$(cygpath -w -p $GOPATH) fi diff --git a/hack/install-tools.sh b/hack/install-tools.sh index 6bd797a2d..a584ec8a7 100755 --- a/hack/install-tools.sh +++ b/hack/install-tools.sh @@ -8,6 +8,6 @@ STARTTIME=$(date +%s) echo $(go version) -go get github.com/tools/godep golang.org/x/lint/golint +GO111MODULE=off go get golang.org/x/lint/golint ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" diff --git a/hack/test-go.sh b/hack/test-go.sh index a61bc5198..32df51ae5 100755 --- a/hack/test-go.sh +++ b/hack/test-go.sh @@ -16,8 +16,7 @@ find_test_dirs() { cd "${S2I_ROOT}" find . -not \( \ \( \ - -wholename './Godeps' \ - -o -wholename './release' \ + -wholename './release' \ -o -wholename './target' \ -o -wholename './vendor' \ -o -wholename '*/_output/*' \ diff --git a/hack/verify-deps.sh b/hack/verify-deps.sh index 228d880a4..dce0c8513 100755 --- a/hack/verify-deps.sh +++ b/hack/verify-deps.sh @@ -7,6 +7,6 @@ set -o pipefail S2I_ROOT=$(dirname "${BASH_SOURCE}")/.. source "${S2I_ROOT}/hack/common.sh" -s2i::build::build_binaries tools/depchecker - -_output/local/go/bin/depchecker +# double check the dependencies stored in vendor directory with the described dependency list in +# local Go Module files, go.mod and go.sum. +go mod verify \ No newline at end of file diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh index 0c76a549c..eba1345f6 100755 --- a/hack/verify-golint.sh +++ b/hack/verify-golint.sh @@ -8,7 +8,7 @@ echo $(go version) if ! which golint &>/dev/null; then echo "Unable to detect 'golint' package" - echo "To install it, run: 'go get github.com/golang/lint/golint'" + echo "To install it, run: 'go get -u golang.org/x/lint/golint'" exit 1 fi