github.com/moby/docker@v26.1.3+incompatible/hack/with-go-mod.sh (about) 1 #!/usr/bin/env bash 2 # 3 # This script is used to coerce certain commands which rely on the presence of 4 # a go.mod into working with our repository. It works by creating a fake 5 # go.mod, running a specified command (passed via arguments), and removing it 6 # when the command is finished. This script should be dropped when this 7 # repository is a proper Go module with a permanent go.mod. 8 9 set -e 10 11 SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 12 ROOTDIR="$(cd "${SCRIPTDIR}/.." && pwd)" 13 14 if test -e "${ROOTDIR}/go.mod"; then 15 { 16 scriptname=$(basename "$0") 17 cat >&2 <<- EOF 18 $scriptname: WARN: go.mod exists in the repository root! 19 $scriptname: WARN: Using your go.mod instead of our generated version -- this may misbehave! 20 EOF 21 } >&2 22 else 23 set -x 24 25 tee "${ROOTDIR}/go.mod" >&2 <<- EOF 26 module github.com/docker/docker 27 28 go 1.21 29 EOF 30 trap 'rm -f "${ROOTDIR}/go.mod"' EXIT 31 fi 32 33 GO111MODULE=on GOTOOLCHAIN=local "$@"