sandbox: pass experiments to vet

Experiments extracted from GOEXPERIMENT were not being passed to vet.
Some experiments, such as aliastypeparams, affect vet as well, and so
must be set in the vet environment.

Change-Id: I7d72c50f5237753b84d26a27fbb09d9bfcf34626
Reviewed-on: https://go-review.googlesource.com/c/playground/+/612456
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
diff --git a/sandbox.go b/sandbox.go
index 91cf0ea..0e1411a 100644
--- a/sandbox.go
+++ b/sandbox.go
@@ -503,7 +503,7 @@
 	}
 	if vet {
 		// TODO: do this concurrently with the execution to reduce latency.
-		br.vetOut, err = vetCheckInDir(ctx, tmpDir, br.goPath)
+		br.vetOut, err = vetCheckInDir(ctx, tmpDir, br.goPath, exp)
 		if err != nil {
 			return nil, fmt.Errorf("running vet: %v", err)
 		}
@@ -512,7 +512,7 @@
 }
 
 // sandboxRun runs a Go binary in a sandbox environment.
-func sandboxRun(ctx context.Context, exePath string, testParam string) (execRes sandboxtypes.Response, err error) {
+func sandboxRun(ctx context.Context, exePath, testParam string) (execRes sandboxtypes.Response, err error) {
 	start := time.Now()
 	defer func() {
 		status := "success"
diff --git a/vet.go b/vet.go
index d58c0f7..14580fb 100644
--- a/vet.go
+++ b/vet.go
@@ -36,7 +36,7 @@
 	if err := os.WriteFile(in, []byte(req.Body), 0400); err != nil {
 		return nil, fmt.Errorf("error creating temp file %q: %v", in, err)
 	}
-	vetOutput, err := vetCheckInDir(ctx, tmpDir, os.Getenv("GOPATH"))
+	vetOutput, err := vetCheckInDir(ctx, tmpDir, os.Getenv("GOPATH"), nil)
 	if err != nil {
 		// This is about errors running vet, not vet returning output.
 		return nil, err
@@ -49,7 +49,7 @@
 // go vet was able to run, not whether vet reported problem. The
 // returned value is ("", nil) if vet successfully found nothing,
 // and (non-empty, nil) if vet ran and found issues.
-func vetCheckInDir(ctx context.Context, dir, goPath string) (output string, execErr error) {
+func vetCheckInDir(ctx context.Context, dir, goPath string, experiments []string) (output string, execErr error) {
 	start := time.Now()
 	defer func() {
 		status := "success"
@@ -72,6 +72,9 @@
 		"GO111MODULE=on",
 		"GOPROXY="+playgroundGoproxy(),
 	)
+	if len(experiments) > 0 {
+		cmd.Env = append(cmd.Env, "GOEXPERIMENT="+strings.Join(experiments, ","))
+	}
 	out, err := cmd.CombinedOutput()
 	if err == nil {
 		return "", nil