Make golang::setup-env turn on workspaces

Both GO111MODULE and GOWORK default to on, so this just unsets them.  We
could set them to explicit values but this seems equivalent and cleaner.
This commit is contained in:
Tim Hockin 2024-02-28 11:43:18 -08:00
parent 2e2ae029c3
commit 81ba0f3b44
No known key found for this signature in database
4 changed files with 14 additions and 13 deletions

View File

@ -582,8 +582,9 @@ kube::golang::setup_env() {
# Cross-compiles will not work with it set.
unset GOBIN
# Explicitly turn on modules.
export GO111MODULE=on
# Turn on modules and workspaces (both are default-on).
unset GO111MODULE
unset GOWORK
# This may try to download our specific Go version. Do it last so it uses
# the above-configured environment.

View File

@ -25,10 +25,6 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
# Set the Go environment, otherwise we get "can't compute 'all' using the
# vendor directory".
export GOWORK=off
export GOFLAGS=-mod=mod
# Detect problematic GOPROXY settings that prevent lookup of dependencies
if [[ "${GOPROXY:-}" == "off" ]]; then
kube::log::error "Cannot run with \$GOPROXY=off"
@ -38,6 +34,11 @@ fi
kube::golang::setup_env
kube::util::require-jq
# Set the Go environment, otherwise we get "can't compute 'all' using the
# vendor directory".
export GOWORK=off
export GOFLAGS=-mod=mod
# let us log all errors before we exit
rc=0

View File

@ -25,17 +25,18 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
# Detect problematic GOPROXY settings that prevent lookup of dependencies
if [[ "${GOPROXY:-}" == "off" ]]; then
kube::log::error "Cannot run with \$GOPROXY=off"
exit 1
fi
kube::golang::setup_env
kube::util::require-jq
# Explicitly set GOFLAGS to ignore vendor, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
export GOWORK=off
export GOFLAGS=-mod=mod
# Detect problematic GOPROXY settings that prevent lookup of dependencies
if [[ "${GOPROXY:-}" == "off" ]]; then
kube::log::error "Cannot run with \$GOPROXY=off"
exit 1
fi
dep="${1:-}"
sha="${2:-}"

View File

@ -41,8 +41,6 @@ $ kind create cluster --config test/e2e/dra/kind.yaml --image dra/node:latest
- Build ginkgo
> NB: If you are using go workspace you must disable it `GOWORK=off make ginkgo`
```bash
$ make ginkgo
```