From e84adf611f4b92a6af4394c95a6f277c60fd2e44 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 5 Jan 2024 22:46:14 -0800 Subject: [PATCH] Remove references to "GO111MODULE" --- hack/lib/golang.sh | 2 +- hack/lib/init.sh | 6 ------ hack/lint-dependencies.sh | 2 +- hack/make-rules/test.sh | 4 ++-- hack/update-internal-modules.sh | 4 +--- hack/update-netparse-cve.sh | 3 --- hack/update-vanity-imports.sh | 2 +- hack/update-yamlfmt.sh | 1 - hack/verify-external-dependencies-version.sh | 2 +- hack/verify-go-workspace.sh | 1 - hack/verify-golangci-lint.sh | 3 --- hack/verify-spelling.sh | 2 +- staging/src/k8s.io/sample-cli-plugin/README.md | 2 +- 13 files changed, 9 insertions(+), 25 deletions(-) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 194c33c233c..978ba6727e6 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -597,7 +597,7 @@ kube::golang::setup_gomaxprocs() { if ! command -v ncpu >/dev/null 2>&1; then # shellcheck disable=SC2164 pushd "${KUBE_ROOT}/hack/tools" >/dev/null - GO111MODULE=on go install ./ncpu || echo "Will not automatically set GOMAXPROCS" + go install ./ncpu || echo "Will not automatically set GOMAXPROCS" # shellcheck disable=SC2164 popd >/dev/null fi diff --git a/hack/lib/init.sh b/hack/lib/init.sh index fd1d6868ca0..7e7aff17631 100755 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -25,12 +25,6 @@ set -o pipefail # https://github.com/kubernetes/kubernetes/issues/52255 unset CDPATH -# Until all GOPATH references are removed from all build scripts as well, -# explicitly disable module mode to avoid picking up user-set GO111MODULE preferences. -# As individual scripts (like hack/update-vendor.sh) make use of go modules, -# they can explicitly set GO111MODULE=on -export GO111MODULE=off - # FIXME(dims): Note that here we assume that if GOFLAGS are already set we # leave them as-is and not try to add providerless to it. So if you # really need to set your own GOFLAGS, ensure you add "providerless" explicitly diff --git a/hack/lint-dependencies.sh b/hack/lint-dependencies.sh index a62c093f27e..cc0e204f141 100755 --- a/hack/lint-dependencies.sh +++ b/hack/lint-dependencies.sh @@ -87,7 +87,7 @@ unused=$(comm -23 \ if [[ -n "${unused}" ]]; then echo "" echo "Use the given commands to remove pinned module versions that aren't actually used:" - echo "${unused}" | xargs -L 1 echo 'GO111MODULE=on go mod edit -dropreplace' + echo "${unused}" | xargs -L 1 echo 'go mod edit -dropreplace' fi if [[ -n "${unused}${outdated}${noncanonical}" ]]; then diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index e59e3daa6ed..949862fc7ce 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -192,7 +192,7 @@ produceJUnitXMLReport() { if ! command -v gotestsum >/dev/null 2>&1; then kube::log::status "gotestsum not found; installing from hack/tools" pushd "${KUBE_ROOT}/hack/tools" >/dev/null - GO111MODULE=on go install gotest.tools/gotestsum + go install gotest.tools/gotestsum popd >/dev/null fi gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout @@ -203,7 +203,7 @@ produceJUnitXMLReport() { if ! command -v prune-junit-xml >/dev/null 2>&1; then kube::log::status "prune-junit-xml not found; installing from hack/tools" pushd "${KUBE_ROOT}/cmd/prune-junit-xml" >/dev/null - GO111MODULE=on go install . + go install . popd >/dev/null fi prune-junit-xml "${junit_xml_filename}" diff --git a/hack/update-internal-modules.sh b/hack/update-internal-modules.sh index 88db414479c..4b81ca00afe 100755 --- a/hack/update-internal-modules.sh +++ b/hack/update-internal-modules.sh @@ -29,15 +29,13 @@ MODULES=( staging/src/k8s.io/kms/internal/plugins/_mock ) -# Explicitly opt into go modules -export GO111MODULE=on - # Detect problematic GOPROXY settings that prevent lookup of dependencies if [[ "${GOPROXY:-}" == "off" ]]; then kube::log::error "Cannot run hack/update-internal-modules.sh with \$GOPROXY=off" exit 1 fi +kube::golang::setup_env kube::golang::verify_go_version for mod in "${MODULES[@]}"; do diff --git a/hack/update-netparse-cve.sh b/hack/update-netparse-cve.sh index 3f51cd60a44..44fca785f59 100755 --- a/hack/update-netparse-cve.sh +++ b/hack/update-netparse-cve.sh @@ -35,9 +35,6 @@ kube::golang::verify_go_version export GOBIN="${KUBE_OUTPUT_BIN}" PATH="${GOBIN}:${PATH}" -# Explicitly opt into go modules -export GO111MODULE=on - # Install golangci-lint echo 'installing net parser converter' pushd "${KUBE_ROOT}/hack/tools" >/dev/null diff --git a/hack/update-vanity-imports.sh b/hack/update-vanity-imports.sh index 80b08ded073..d30653fb7a2 100755 --- a/hack/update-vanity-imports.sh +++ b/hack/update-vanity-imports.sh @@ -27,7 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::verify_go_version pushd "${KUBE_ROOT}/hack/tools" >/dev/null - GO111MODULE=on go install github.com/jcchavezs/porto/cmd/porto + go install github.com/jcchavezs/porto/cmd/porto popd >/dev/null porto --restrict-to-dirs="staging" --restrict-to-files="doc\\.go$" -w "${KUBE_ROOT}" diff --git a/hack/update-yamlfmt.sh b/hack/update-yamlfmt.sh index 1f6622a5bd1..ad65c0f8593 100755 --- a/hack/update-yamlfmt.sh +++ b/hack/update-yamlfmt.sh @@ -38,5 +38,4 @@ find_files() { \) -name 'OWNERS*' } -export GO111MODULE=on find_files | xargs go run cmd/yamlfmt/yamlfmt.go diff --git a/hack/verify-external-dependencies-version.sh b/hack/verify-external-dependencies-version.sh index 67efc39915f..5419c860875 100755 --- a/hack/verify-external-dependencies-version.sh +++ b/hack/verify-external-dependencies-version.sh @@ -32,7 +32,7 @@ export GOBIN="${KUBE_OUTPUT_BIN}" PATH="${GOBIN}:${PATH}" # Install zeitgeist -GO111MODULE=on go install sigs.k8s.io/zeitgeist@v0.2.0 +go install sigs.k8s.io/zeitgeist@v0.2.0 # Prefer full path for running zeitgeist ZEITGEIST_BIN="$(which zeitgeist)" diff --git a/hack/verify-go-workspace.sh b/hack/verify-go-workspace.sh index 8366f6566ed..334c892ad45 100755 --- a/hack/verify-go-workspace.sh +++ b/hack/verify-go-workspace.sh @@ -27,5 +27,4 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/verify-generated.sh" -export GO111MODULE=on # TODO(thockin): remove this when init.sh stops disabling it kube::verify::generated "Go workspace files need to be updated" "Please run 'hack/update-go-workspace.sh'" hack/update-go-workspace.sh diff --git a/hack/verify-golangci-lint.sh b/hack/verify-golangci-lint.sh index 72cb0d7d8bd..8531a2db7d6 100755 --- a/hack/verify-golangci-lint.sh +++ b/hack/verify-golangci-lint.sh @@ -126,9 +126,6 @@ for arg; do fi done -# Explicitly opt into go modules -export GO111MODULE=on - # Install golangci-lint echo "installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN}" pushd "${KUBE_ROOT}/hack/tools" >/dev/null diff --git a/hack/verify-spelling.sh b/hack/verify-spelling.sh index 9084eb251f2..67ca4a419b0 100755 --- a/hack/verify-spelling.sh +++ b/hack/verify-spelling.sh @@ -33,7 +33,7 @@ PATH="${GOBIN}:${PATH}" # Install tools we need pushd "${KUBE_ROOT}/hack/tools" >/dev/null - GO111MODULE=on go install github.com/client9/misspell/cmd/misspell + go install github.com/client9/misspell/cmd/misspell popd >/dev/null # Spell checking diff --git a/staging/src/k8s.io/sample-cli-plugin/README.md b/staging/src/k8s.io/sample-cli-plugin/README.md index 0aa94e58d6e..1c34824a378 100644 --- a/staging/src/k8s.io/sample-cli-plugin/README.md +++ b/staging/src/k8s.io/sample-cli-plugin/README.md @@ -31,7 +31,7 @@ This is an example of how to build a kubectl plugin using the same set of tools ```sh # assumes you have a working KUBECONFIG -$ GO111MODULE="on" go build cmd/kubectl-ns.go +$ go build cmd/kubectl-ns.go # place the built binary somewhere in your PATH $ cp ./kubectl-ns /usr/local/bin