cmd/cue: use gotooltest within testscript tests

This obviates the need for any per-script setup of HOME, USERPROFILE and
LOCALAPPDATA, whilst also making the command "go" available natively
within a script.

In preparation for later cue get go changes/fixes.

Change-Id: I03d396c8d381f2f67bb15a348cbec464042af611
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8290
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
diff --git a/cmd/cue/cmd/script_test.go b/cmd/cue/cmd/script_test.go
index b11555b..004b5e4 100644
--- a/cmd/cue/cmd/script_test.go
+++ b/cmd/cue/cmd/script_test.go
@@ -26,6 +26,7 @@
 	"strings"
 	"testing"
 
+	"github.com/rogpeppe/go-internal/gotooltest"
 	"github.com/rogpeppe/go-internal/testscript"
 	"github.com/rogpeppe/go-internal/txtar"
 
@@ -71,10 +72,14 @@
 }
 
 func TestScript(t *testing.T) {
-	testscript.Run(t, testscript.Params{
+	p := testscript.Params{
 		Dir:           "testdata/script",
 		UpdateScripts: *update,
-	})
+	}
+	if err := gotooltest.Setup(&p); err != nil {
+		t.Fatal(err)
+	}
+	testscript.Run(t, p)
 }
 
 // TestScriptDebug takes a single testscript file and then runs it within the
diff --git a/cmd/cue/cmd/testdata/script/get_go_basic.txt b/cmd/cue/cmd/testdata/script/get_go_basic.txt
index a82b230..e0fc4f3 100644
--- a/cmd/cue/cmd/testdata/script/get_go_basic.txt
+++ b/cmd/cue/cmd/testdata/script/get_go_basic.txt
@@ -1,10 +1,5 @@
 # Test that a basic get go works using golden files to verify output
 
-# Set HOME for go-build cache to be valid
-env HOME=$WORK${/}home
-env USERPROFILE=$HOME
-env LOCALAPPDATA=$WORK${/}appdata
-
 # All the things
 cue get go --local
 cmp blah_go_gen.cue all.cue.golden
diff --git a/cmd/cue/cmd/testdata/script/go_cmd.txt b/cmd/cue/cmd/testdata/script/go_cmd.txt
new file mode 100644
index 0000000..313112a
--- /dev/null
+++ b/cmd/cue/cmd/testdata/script/go_cmd.txt
@@ -0,0 +1,6 @@
+# Basic sanity check that go command works as expected
+# within testscript tests
+
+go version
+stdout '^go version'
+