Skip to content

Commit 6c1c0c5

Browse files
authored
Merge pull request #41 from infosiftr/more-windows
Apply more Windows fixes (especially for Cygwin / our Windows Server)
2 parents 61c78d9 + 164596d commit 6c1c0c5

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

.go-env.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,43 @@ dir="$(readlink -ve "$dir")"
66

77
src="$dir"
88
dst="$dir"
9+
tmp='/tmp'
10+
goDir='/go'
11+
912
msys=
10-
if [ "$(uname -o)" = 'Msys' ]; then
11-
msys=1
12-
if command -v cygpath > /dev/null; then
13-
src="$(cygpath --windows "$dst")"
14-
fi
13+
cygwin=
14+
case "$(uname -o)" in
15+
Msys)
16+
msys=1
17+
;;
18+
Cygwin)
19+
cygwin=1
20+
;;
21+
esac
22+
if [ -n "${msys:-$cygwin}" ] && command -v cygpath > /dev/null; then
23+
src="$(cygpath --windows "$dst")"
1524
fi
1625
windowsContainers=
1726
serverOs="$(docker version --format '{{ .Server.Os }}')"
1827
if [ "$serverOs" = 'windows' ]; then
1928
windowsContainers=1
2029
# normally we'd want this to match $src so error messages, traces, etc are easier to follow, but $src might be on a non-C: drive letter and not be usable in the container as-is 😭
2130
dst='C:\app'
31+
tmp='C:\Temp'
32+
goDir='C:\go'
2233
fi
2334

2435
args=(
2536
--interactive --rm --init
2637
--mount "type=bind,src=$src,dst=$dst"
2738
--workdir "$dst"
28-
--tmpfs /tmp,exec
29-
--env HOME=/tmp
39+
--tmpfs "$tmp",exec
40+
--env HOME="$tmp"
3041

3142
# "go mod" cache is stored in /go/pkg/mod/cache
32-
--env GOPATH=/go
33-
--mount type=volume,src=doi-meta-gopath,dst=/go
34-
--env GOCACHE=/go/.cache
43+
--env GOPATH="$goDir"
44+
--mount type=volume,src=doi-meta-gopath,dst="$goDir"
45+
--env GOCACHE="$goDir/.cache"
3546

3647
--env "CGO_ENABLED=${CGO_ENABLED-0}"
3748
--env "GOTOOLCHAIN=${GOTOOLCHAIN-local}"
@@ -57,7 +68,7 @@ fi
5768
winpty=()
5869
if [ -t 0 ] && [ -t 1 ]; then
5970
args+=( --tty )
60-
if [ -n "$msys" ]; then
71+
if [ -n "$msys" ] && command -v winpty > /dev/null; then
6172
winpty=( winpty )
6273
fi
6374
fi

0 commit comments

Comments
 (0)