]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/objabi: make GOEXPERIMENT be a diff from default experiments
authorAustin Clements <austin@google.com>
Tue, 6 Apr 2021 20:11:17 +0000 (16:11 -0400)
committerAustin Clements <austin@google.com>
Thu, 8 Apr 2021 02:17:20 +0000 (02:17 +0000)
commita8e55538af40905961c263d980760b76e9c43593
tree5eab170e3d6a05b0806cda14891b13a611f290d5
parent89ca1ce9a8fbb70800fe24cc13aa267c3c90aadb
cmd/internal/objabi: make GOEXPERIMENT be a diff from default experiments

Right now the rules around handling default-on experiments are
complicated and a bit inconsistent. Notably, objabi.GOEXPERIMENT is
set to a comma-separated list of enabled experiments, but this may not
be the string a user should set the GOEXPERIMENT environment variable
to get that list of experiments: if an experiment is enabled by
default but gets turned off by GOEXPERIMENT, then the string we report
needs to include "no"+experiment to capture that default override.

This complication also seeps into the version string we print for "go
tool compile -V", etc. This logic is further complicated by the fact
that it only wants to include an experiment string if the set of
experiments varies from the default.

This CL rethinks how we handle default-on experiments. Now that
experiment state is all captured in a struct, we can simplify a lot of
this logic. objabi.GOEXPERIMENT will be set based on the delta from
the default set of experiments, which reflects what a user would
actually need to pass on the command line. Likewise, we include this
delta in the "-V" output, which simplifies this logic because if
there's nothing to show in the version string, the delta will be
empty.

Change-Id: I7ed307329541fc2c9f90edd463fbaf8e0cc9e8ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/307819
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/go/script_test.go
src/cmd/go/testdata/script/README
src/cmd/go/testdata/script/build_tag_goexperiment.txt
src/cmd/internal/objabi/exp.go
src/cmd/internal/objabi/flag.go
src/cmd/internal/objabi/util.go
src/internal/goexperiment/flags.go