2022-11-18 15:29:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# This script is used to coerce certain commands which rely on the presence of
|
|
|
|
# a go.mod into working with our repository. It works by creating a fake
|
|
|
|
# go.mod, running a specified command (passed via arguments), and removing it
|
|
|
|
# when the command is finished. This script should be dropped when this
|
|
|
|
# repository is a proper Go module with a permanent go.mod.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
2023-07-11 13:36:03 +00:00
|
|
|
ROOTDIR="$(cd "${SCRIPTDIR}/.." && pwd)"
|
2022-11-18 15:29:06 +00:00
|
|
|
|
|
|
|
if test -e "${ROOTDIR}/go.mod"; then
|
|
|
|
{
|
|
|
|
scriptname=$(basename "$0")
|
2023-07-18 14:23:39 +00:00
|
|
|
cat >&2 <<- EOF
|
|
|
|
$scriptname: WARN: go.mod exists in the repository root!
|
|
|
|
$scriptname: WARN: Using your go.mod instead of our generated version -- this may misbehave!
|
|
|
|
EOF
|
2022-11-18 15:29:06 +00:00
|
|
|
} >&2
|
|
|
|
else
|
|
|
|
set -x
|
|
|
|
|
|
|
|
tee "${ROOTDIR}/go.mod" >&2 <<- EOF
|
|
|
|
module github.com/docker/docker
|
|
|
|
|
2024-02-20 09:51:18 +00:00
|
|
|
go 1.21
|
2022-11-18 15:29:06 +00:00
|
|
|
EOF
|
|
|
|
trap 'rm -f "${ROOTDIR}/go.mod"' EXIT
|
|
|
|
fi
|
|
|
|
|
2024-02-20 09:51:18 +00:00
|
|
|
GO111MODULE=on GOTOOLCHAIN=local "$@"
|