scripts: replacing scripts/build/go with "veyron go"

Change-Id: Ie5c3399ddc1c44664368c23fb2f258cf697b5276
diff --git a/runtimes/google/ipc/benchmarks/README.txt b/runtimes/google/ipc/benchmarks/README.txt
index 129c66f..f480100 100644
--- a/runtimes/google/ipc/benchmarks/README.txt
+++ b/runtimes/google/ipc/benchmarks/README.txt
@@ -21,7 +21,7 @@
 
 On a ThinkPad X1 Carbon (2 × Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz), we get:
 
-$ $VEYRON_ROOT/scripts/build/go test -test.bench=. -test.cpu=1 \
+$ veyron go test -test.bench=. -test.cpu=1 \
 	-test.benchtime=5s veyron/runtimes/google/ipc/benchmarks 2> /dev/null
 PASS
 Benchmark____1B	   10000	    545077 ns/op
diff --git a/runtimes/google/ipc/stream/crypto/tls_generate_old.sh b/runtimes/google/ipc/stream/crypto/tls_generate_old.sh
index 66a23c5..b940345 100755
--- a/runtimes/google/ipc/stream/crypto/tls_generate_old.sh
+++ b/runtimes/google/ipc/stream/crypto/tls_generate_old.sh
@@ -25,7 +25,7 @@
     sed -e 's|// +build go1.4|// +build !go1.4|' |
     sed -e 's|"crypto/tls"|tls "veyron.io/veyron/veyron/runtimes/google/ipc/stream/crypto/tlsfork"|' >>$OUTFILE
 
-  "${VEYRON_ROOT}/scripts/build/go" fmt "${OUTFILE}"
+  veyron go fmt "${OUTFILE}"
 }
 
 main "$@"
diff --git a/security/agent/test.sh b/security/agent/test.sh
index 8d031af..a259b89 100755
--- a/security/agent/test.sh
+++ b/security/agent/test.sh
@@ -5,9 +5,8 @@
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/security/agent/agentd || shell_test::fail "line ${LINENO}: failed to build agentd"
-  "${GO}" build -o pingpong veyron.io/veyron/veyron/security/agent/test || shell_test::fail "line ${LINENO}: failed to build pingpong"
+  veyron go build veyron.io/veyron/veyron/security/agent/agentd || shell_test::fail "line ${LINENO}: failed to build agentd"
+  veyron go build -o pingpong veyron.io/veyron/veyron/security/agent/test || shell_test::fail "line ${LINENO}: failed to build pingpong"
 }
 
 main() {
diff --git a/services/mgmt/application/applicationd/test.sh b/services/mgmt/application/applicationd/test.sh
index 3ee6e55..b6173f2 100755
--- a/services/mgmt/application/applicationd/test.sh
+++ b/services/mgmt/application/applicationd/test.sh
@@ -9,9 +9,8 @@
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/services/mgmt/application/applicationd || shell_test::fail "line ${LINENO}: failed to build 'applicationd'"
-  "${GO}" build veyron.io/veyron/veyron/tools/application || shell_test::fail "line ${LINENO}: failed to build 'application'"
+  veyron go build veyron.io/veyron/veyron/services/mgmt/application/applicationd || shell_test::fail "line ${LINENO}: failed to build 'applicationd'"
+  veyron go build veyron.io/veyron/veyron/tools/application || shell_test::fail "line ${LINENO}: failed to build 'application'"
 }
 
 main() {
diff --git a/services/mgmt/binary/binaryd/test.sh b/services/mgmt/binary/binaryd/test.sh
index ce75d4c..c78a028 100755
--- a/services/mgmt/binary/binaryd/test.sh
+++ b/services/mgmt/binary/binaryd/test.sh
@@ -9,9 +9,8 @@
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/services/mgmt/binary/binaryd || shell_test::fail "line ${LINENO}: failed to build 'binaryd'"
-  "${GO}" build veyron.io/veyron/veyron/tools/binary || shell_test::fail "line ${LINENO}: failed to build 'binary'"
+  veyron go build veyron.io/veyron/veyron/services/mgmt/binary/binaryd || shell_test::fail "line ${LINENO}: failed to build 'binaryd'"
+  veyron go build veyron.io/veyron/veyron/tools/binary || shell_test::fail "line ${LINENO}: failed to build 'binary'"
 }
 
 main() {
diff --git a/services/mgmt/build/buildd/test.sh b/services/mgmt/build/buildd/test.sh
index 018cd81..e8d6b30 100755
--- a/services/mgmt/build/buildd/test.sh
+++ b/services/mgmt/build/buildd/test.sh
@@ -5,22 +5,11 @@
 # This test starts a build server daemon and uses the build client to
 # verify that <build>.Build() works as expected.
 
-# shell_test.sh must be sourced *last* Because it has a "trap" statement that
-# cleans up processes on exit and we want to avoid this trap statement being
-# overridden by other scripts.  For example, go.sh sources a script which sets
-# up a different trap handler and thus, if go.sh is sourced second, then it
-# overrides the trap handler setup in shell_test.sh.
-# TODO(jsimsa,ashankar): Figure out a way to execute all trap handlers instead
-# of having to worry about ordering the imports and/or skipping some trap
-# handlers.
-
-source "${VEYRON_ROOT}/scripts/lib/go.sh"
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/services/mgmt/build/buildd || shell_test::fail "line ${LINENO}: failed to build 'buildd'"
-  "${GO}" build veyron.io/veyron/veyron/tools/build || shell_test::fail "line ${LINENO}: failed to build 'build'"
+  veyron go build veyron.io/veyron/veyron/services/mgmt/build/buildd || shell_test::fail "line ${LINENO}: failed to build 'buildd'"
+  veyron go build veyron.io/veyron/veyron/tools/build || shell_test::fail "line ${LINENO}: failed to build 'build'"
 }
 
 main() {
@@ -32,12 +21,7 @@
   # Start the binary repository daemon.
   local -r SERVER="buildd-test-server"
   local GO_BIN=$(which go)
-  if [[ -n "${GO_BIN}" ]] && go::usable_release "${GO_BIN}"; then
-    local -r GO_ROOT=$(go env GOROOT)
-  else
-    local -r GO_ROOT="${VEYRON_ROOT}/environment/go/$(go::os)/$(go::architecture)/go"
-    GO_BIN="${GO_ROOT}/bin/go"
-  fi
+  local -r GO_ROOT=$("${GO_BIN}" env GOROOT)
   shell_test::start_server ./buildd --name="${SERVER}" --gobin="${GO_BIN}" --goroot="${GO_ROOT}" --address=127.0.0.1:0
 
   # Create and build a test source file.
diff --git a/services/mgmt/profile/profiled/test.sh b/services/mgmt/profile/profiled/test.sh
index c43a418..1f65ae0 100755
--- a/services/mgmt/profile/profiled/test.sh
+++ b/services/mgmt/profile/profiled/test.sh
@@ -10,9 +10,8 @@
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/services/mgmt/profile/profiled || shell_test::fail "line ${LINENO}: failed to build 'profiled'"
-  "${GO}" build veyron.io/veyron/veyron/tools/profile || shell_test::fail "line ${LINENO}: failed to build 'profile'"
+  veyron go build veyron.io/veyron/veyron/services/mgmt/profile/profiled || shell_test::fail "line ${LINENO}: failed to build 'profiled'"
+  veyron go build veyron.io/veyron/veyron/tools/profile || shell_test::fail "line ${LINENO}: failed to build 'profile'"
 }
 
 main() {
diff --git a/services/mounttable/mounttabled/test.sh b/services/mounttable/mounttabled/test.sh
index e6983d3..144633b 100755
--- a/services/mounttable/mounttabled/test.sh
+++ b/services/mounttable/mounttabled/test.sh
@@ -12,9 +12,8 @@
 source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/services/mounttable/mounttabled || shell_test::fail "line ${LINENO}: failed to build mounttabled"
-  "${GO}" build veyron.io/veyron/veyron/tools/mounttable || shell_test::fail "line ${LINENO}: failed to build mounttable"
+  veyron go build veyron.io/veyron/veyron/services/mounttable/mounttabled || shell_test::fail "line ${LINENO}: failed to build mounttabled"
+  veyron go build veyron.io/veyron/veyron/tools/mounttable || shell_test::fail "line ${LINENO}: failed to build mounttable"
 }
 
 main() {
diff --git a/tools/identity/test.sh b/tools/identity/test.sh
index b35dc26..a3290d3 100755
--- a/tools/identity/test.sh
+++ b/tools/identity/test.sh
@@ -11,8 +11,7 @@
 main() {
   # Build binaries.
   cd "${TMPDIR}"
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build identity"
+  veyron go build veyron.io/veyron/veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build identity"
 
   ./identity print >/dev/null || shell_test::fail "line ${LINENO}: print failed"
   ./identity generate >/dev/null || shell_test::fail "line ${LINENO}: generate failed"
diff --git a/tools/playground/builder/Dockerfile b/tools/playground/builder/Dockerfile
index a1dcfac..e06d726 100644
--- a/tools/playground/builder/Dockerfile
+++ b/tools/playground/builder/Dockerfile
@@ -28,7 +28,7 @@
 # Install Veyron Go dependencies.
 WORKDIR /usr/local/veyron/veyron
 ENV PATH /usr/local/veyron/veyron/go/bin:/usr/local/bin:/usr/bin:/bin
-RUN $VEYRON_ROOT/scripts/build/go install veyron.io/veyron/...
+RUN veyron go install veyron.io/veyron/...
 
 # Uncomment the following lines to install a version of the builder tool using
 # the local copy of vbuild.go.  This is useful when developing and testing
@@ -37,7 +37,7 @@
 # ADD vbuild.go /usr/local/veyron/veyron/go/src/veyron/tools/playground/builder/vbuild.go
 # ADD identity.go /usr/local/veyron/veyron/go/src/veyron/tools/playground/builder/identity.go
 # ADD services.go /usr/local/veyron/veyron/go/src/veyron/tools/playground/builder/services.go
-# RUN $VEYRON_ROOT/scripts/build/go install veyron/tools/playground/builder
+# RUN veyron go install veyron/tools/playground/builder
 
 USER playground
 WORKDIR /home/playground
diff --git a/tools/playground/builder/vbuild.go b/tools/playground/builder/vbuild.go
index d0f64b4..9eac10e 100644
--- a/tools/playground/builder/vbuild.go
+++ b/tools/playground/builder/vbuild.go
@@ -291,7 +291,7 @@
 	case "vdl":
 		cmd = makeCmdJsonEvent(f.Name, "vdl", "generate", "--lang=go", f.pkg)
 	case "go":
-		cmd = makeCmdJsonEvent(f.Name, filepath.Join(os.Getenv("VEYRON_ROOT"), "scripts", "build", "go"), "install", f.pkg)
+		cmd = makeCmdJsonEvent(f.Name, "veyron", "go", "install", f.pkg)
 	default:
 		return fmt.Errorf("Can't compile file %s with language %s.", f.Name, f.lang)
 	}
diff --git a/tools/playground/test.sh b/tools/playground/test.sh
index 29d36e4..31edccd 100755
--- a/tools/playground/test.sh
+++ b/tools/playground/test.sh
@@ -17,14 +17,13 @@
 }
 
 build() {
-  local -r GO="${VEYRON_ROOT}/scripts/build/go"
-  "${GO}" build veyron.io/veyron/veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build 'identity'"
-  "${GO}" build veyron.io/veyron/veyron/services/proxy/proxyd || shell_test::fail "line ${LINENO}: failed to build 'proxyd'"
-  "${GO}" build veyron.io/veyron/veyron/services/mounttable/mounttabled || shell_test::fail "line ${LINENO}: failed to build 'mounttabled'"
-  "${GO}" build veyron.io/veyron/veyron/services/wsprd || shell_test::fail "line ${LINENO}: failed to build 'wsprd'"
-  "${GO}" build veyron.io/veyron/veyron2/vdl/vdl || shell_test::fail "line ${LINENO}: failed to build 'vdl'"
-  "${GO}" build veyron.io/veyron/veyron/tools/playground/builder || shell_test::fail "line ${LINENO}: failed to build 'builder'"
-  "${GO}" build veyron.io/veyron/veyron/tools/playground/testdata/escaper || shell_test::fail "line ${LINENO}: failed to build 'escaper'"
+  veyron go build veyron.io/veyron/veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build 'identity'"
+  veyron go build veyron.io/veyron/veyron/services/proxy/proxyd || shell_test::fail "line ${LINENO}: failed to build 'proxyd'"
+  veyron go build veyron.io/veyron/veyron/services/mounttable/mounttabled || shell_test::fail "line ${LINENO}: failed to build 'mounttabled'"
+  veyron go build veyron.io/veyron/veyron/services/wsprd || shell_test::fail "line ${LINENO}: failed to build 'wsprd'"
+  veyron go build veyron.io/veyron/veyron2/vdl/vdl || shell_test::fail "line ${LINENO}: failed to build 'vdl'"
+  veyron go build veyron.io/veyron/veyron/tools/playground/builder || shell_test::fail "line ${LINENO}: failed to build 'builder'"
+  veyron go build veyron.io/veyron/veyron/tools/playground/testdata/escaper || shell_test::fail "line ${LINENO}: failed to build 'escaper'"
 }
 
 test_with_files() {