all: set CGO_ENABLED=0 when building snippets

GCC has never been available to our build step of the Playground.
Historically, the Playground always built programs with faketime, and
relied on patches for sandboxing in NaCL. In the future, we could enable
CGO programs to be built and run safely in the gVisor sandbox. In the
meantime, this fixes trivial snippets that rely on CGO parts of std.

Fixes golang/go#44714

Change-Id: If0e8b89f3c47bc080954dbd504d9de38295c16e2
Reviewed-on: https://go-review.googlesource.com/c/playground/+/297636
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/sandbox.go b/sandbox.go
index 9a8e8a3..cc47954 100644
--- a/sandbox.go
+++ b/sandbox.go
@@ -468,6 +468,7 @@
 	cmd.Dir = tmpDir
 	cmd.Env = []string{"GOOS=linux", "GOARCH=amd64", "GOROOT=/usr/local/go-faketime"}
 	cmd.Env = append(cmd.Env, "GOCACHE="+goCache)
+	cmd.Env = append(cmd.Env, "CGO_ENABLED=0")
 	// Create a GOPATH just for modules to be downloaded
 	// into GOPATH/pkg/mod.
 	cmd.Args = append(cmd.Args, "-modcacherw")
diff --git a/tests.go b/tests.go
index 760c971..03bc39d 100644
--- a/tests.go
+++ b/tests.go
@@ -567,4 +567,18 @@
 
 }
 `, want: "2012-07-09 05:02:00 +0200 CEST\n2012-07-09 00:00:00 +0200 CEST\n"},
+	{
+		name: "cgo_enabled_0",
+		prog: `
+package main
+
+import (
+	"fmt"
+	"net"
+)
+
+func main() {
+	fmt.Println(net.ParseIP("1.2.3.4"))
+}
+`, want: "1.2.3.4\n"},
 }