Skip to content

Commit 1801748

Browse files
committed
Merge pull request #1734 from fjl/ldflags-warning-go1.5
build: avoid -X separator warning with Go >= 1.5
2 parents e1037bd + cfd84a6 commit 1801748

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

build/ldflags.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ if [ ! -f "build/env.sh" ]; then
77
exit 2
88
fi
99

10+
# Since Go 1.5, the separator char for link time assignments
11+
# is '=' and using ' ' prints a warning. However, Go < 1.5 does
12+
# not support using '='.
13+
sep=$(go version | awk '{ if ($3 >= "go1.5" || index($3, "devel")) print "="; else print " "; }' -)
14+
1015
# set gitCommit when running from a Git checkout.
1116
if [ -f ".git/HEAD" ]; then
12-
echo "-ldflags '-X main.gitCommit $(git rev-parse HEAD)'"
17+
echo "-ldflags '-X main.gitCommit$sep$(git rev-parse HEAD)'"
1318
fi

0 commit comments

Comments
 (0)