Use the same script as is used in moby/moby, which more gracefully handles an existing `go.mod` (which can be symlinked) into account. - keep the scripts called generic, and update the Makefile to invoke them with the "with-go-mod.sh" script. - use "go run" instead of building temporary binaries - check if go-md2man exists before building a binary Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
931 B
Bash
Executable File
34 lines
931 B
Bash
Executable File
#!/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)"
|
|
ROOTDIR="$(cd "${SCRIPTDIR}/.." && pwd)"
|
|
|
|
if test -e "${ROOTDIR}/go.mod"; then
|
|
{
|
|
scriptname=$(basename "$0")
|
|
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
|
|
} >&2
|
|
else
|
|
set -x
|
|
|
|
tee "${ROOTDIR}/go.mod" >&2 <<- EOF
|
|
module github.com/docker/cli
|
|
|
|
go 1.23.0
|
|
EOF
|
|
trap 'rm -f "${ROOTDIR}/go.mod"' EXIT
|
|
fi
|
|
|
|
GO111MODULE=on GOTOOLCHAIN=local "$@"
|