If GOEXPERIMENT environment variable is unset, use the default
value that is baked into the toolchain (instead of no
experiments).
Change-Id: I41f863e6f7439f2d53e3ebd25a7d9cf4a176e32e
Reviewed-on: https://go-review.googlesource.com/c/go/+/309333
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
}
exp := os.Getenv("GOEXPERIMENT")
+ if exp == "" {
+ // If GOEXPERIMENT environment variable is unset, get the default value
+ // that is baked into the toolchain.
+ cmd := exec.Command(goTool(), "tool", "compile", "-V")
+ out, err := cmd.CombinedOutput()
+ if err == nil {
+ i := bytes.Index(out, []byte("X:"))
+ if i != -1 {
+ exp = string(out[i+2:])
+ }
+ }
+ }
if exp != "" {
experiments := strings.Split(exp, ",")
for _, e := range experiments {