[go] Rewrite go wrapper script to use exec_tool.sh.
This script is now only used by //third_party/go/BUILD.gn.
Change-Id: I1590b5dec0f737ccce06e66194b47af33fc654f1
diff --git a/go b/go
index 6bcd5e4..8cb14c2 100755
--- a/go
+++ b/go
@@ -3,21 +3,18 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# This script is only used in building the Fuchsia Go toolchain.
+# See //third_party/go/BUILD.gn.
+
set -e
readonly SCRIPT_ROOT="$(cd $(dirname ${BASH_SOURCE[0]} ) && pwd)"
+# Setting GOROOT is a workaround for https://golang.org/issue/18678.
+# Basically, early Go toolchains were not self-relocating.
+# Remove this when we're using Go 1.9.
source "$SCRIPT_ROOT/vars.sh"
+export GOROOT="$BUILDTOOLS_GO_DIR"
-if [[ "$GOOS" != "fuchsia" || "$GOROOT" == "" ]]; then
- # Setting GOROOT is a workaround for https://golang.org/issue/18678.
- # Remove this (and switch to exec_tool.sh) when Go 1.9 is released.
- export GOROOT="$BUILDTOOLS_GO_DIR"
-fi
-
-if [[ "$GOOS" == "fuchsia" ]]; then
- export ZIRCON="$(cd $(dirname ${BASH_SOURCE[0]} )/.. && pwd)/zircon"
- export CC="$GOROOT/misc/fuchsia/gccwrap.sh"
-fi
-
-exec "$GOROOT/bin/go" "$@"
+readonly TOOL_NAME="go/bin/go"
+source "${SCRIPT_ROOT}/exec_tool.sh"