playground: disable cgo when executing the vet tool
Go binary installed in Docker images is not built with
CGO_ENABLED=0. "go vet" was failing for the programs that
imported packages with cgo files.
This change disables the usage of cgo files in the vet tool.
Fixes golang/go#26307.
Change-Id: I0ce117a94d34b0241d48f91cb8165ab38c47cc2d
Reviewed-on: https://go-review.googlesource.com/123136
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/vet.go b/vet.go
index 314fd40..b4925db 100644
--- a/vet.go
+++ b/vet.go
@@ -29,6 +29,10 @@
}
cmd := exec.Command("go", "vet", in)
+ // Linux go binary is not built with CGO_ENABLED=0.
+ // Prevent vet to compile packages in cgo mode.
+ // See #26307.
+ cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
out, err := cmd.CombinedOutput()
if err == nil {
return &response{}, nil