diff --git a/scripts/packaging/buildpackage.sh b/scripts/packaging/buildpackage.sh index e3ec83ccde9..b49373f1963 100755 --- a/scripts/packaging/buildpackage.sh +++ b/scripts/packaging/buildpackage.sh @@ -2,10 +2,14 @@ set -euo pipefail -export GOROOT="${GOROOT:-/tmp/go}" -export GOPATH="${GOPATH:-/tmp/goroot}" -export PATH="${GOPATH}/bin:$GOROOT/bin:${PATH}" - +if command -v go > /dev/null; then + eval "$(go env)" + export GOROOT GOPATH +else + export GOROOT="${GOROOT:-/tmp/go}" + export GOPATH="${GOPATH:-/tmp/goroot}" + export PATH="${GOPATH}/bin:$GOROOT/bin:${PATH}" +fi cd "$(dirname $0)/../.." if [ -f debian/changelog ]; then