]> Cypherpunks repositories - gostls13.git/commitdiff
internal/buildcfg: set Error instead of panicking
authorAustin Clements <austin@google.com>
Sat, 17 Apr 2021 01:50:46 +0000 (21:50 -0400)
committerAustin Clements <austin@google.com>
Tue, 4 May 2021 18:27:33 +0000 (18:27 +0000)
All build environment validation sets Error except for the
GOEXPERIMENT parser, which panics. Change it to also set Error so that
a bad GOEXPERIMENT doesn't cause everything that imports
internal/buildcfg to panic on init.

Change-Id: Ie9a506ef0978ecb410f2dcd784638f2167354175
Reviewed-on: https://go-review.googlesource.com/c/go/+/310970
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/internal/buildcfg/exp.go

index ef769b54155618b186e951cd90bb02a9758ae138..2435a79dcec8c614f11ee5026425cfe6127399c0 100644 (file)
@@ -108,10 +108,10 @@ func parseExperiments() goexperiment.Flags {
        }
        // Check regabi dependencies.
        if flags.RegabiG && !flags.RegabiWrappers {
-               panic("GOEXPERIMENT regabig requires regabiwrappers")
+               Error = fmt.Errorf("GOEXPERIMENT regabig requires regabiwrappers")
        }
        if flags.RegabiArgs && !(flags.RegabiWrappers && flags.RegabiG && flags.RegabiReflect && flags.RegabiDefer) {
-               panic("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect,regabidefer")
+               Error = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect,regabidefer")
        }
        return flags
 }