File: with-go-mod.sh

package info (click to toggle)
docker.io 26.1.5%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,576 kB
  • sloc: sh: 5,748; makefile: 912; ansic: 664; asm: 228; python: 162
file content (33 lines) | stat: -rwxr-xr-x 932 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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/docker

		go 1.21
	EOF
	trap 'rm -f "${ROOTDIR}/go.mod"' EXIT
fi

GO111MODULE=on GOTOOLCHAIN=local "$@"