mirror of https://github.com/golang/go.git
cmd/go: fix -changed don`t print when GOFIPS140 is non-default
See https://github.com/golang/go/issues/70200#issuecomment-2468562595, GOFIPS140 value when building the toolchain (off when not set) is the default value for GOFIPS140, it is buildcfg.defaultGOFIPS140, export as buildcfg.DefaultGOFIPS140 that can be used in the cmd/go. For #70200 Change-Id: I5a4873a718eeefda8e65bfab51d9d3d5ad2c21b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/629996 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
parent
4671276c5d
commit
f5973c2183
|
|
@ -65,7 +65,7 @@ func mkbuildcfg(file string) {
|
|||
fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion())
|
||||
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
|
||||
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
|
||||
fmt.Fprintf(&buf, "const defaultGOFIPS140 = `%s`\n", gofips140)
|
||||
fmt.Fprintf(&buf, "const DefaultGOFIPS140 = `%s`\n", gofips140)
|
||||
|
||||
writefile(buf.String(), file, writeSkipSame)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ var (
|
|||
GORISCV64, goRISCV64Changed = EnvOrAndChanged("GORISCV64", buildcfg.DefaultGORISCV64)
|
||||
GOWASM, goWASMChanged = EnvOrAndChanged("GOWASM", fmt.Sprint(buildcfg.GOWASM))
|
||||
|
||||
GOFIPS140, GOFIPS140Changed = EnvOrAndChanged("GOFIPS140", buildcfg.GOFIPS140)
|
||||
GOFIPS140, GOFIPS140Changed = EnvOrAndChanged("GOFIPS140", buildcfg.DefaultGOFIPS140)
|
||||
GOPROXY, GOPROXYChanged = EnvOrAndChanged("GOPROXY", "")
|
||||
GOSUMDB, GOSUMDBChanged = EnvOrAndChanged("GOSUMDB", "")
|
||||
GOPRIVATE = Getenv("GOPRIVATE")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ env GOPROXY=nodefault
|
|||
env GO111MODULE=auto
|
||||
env CGO_CFLAGS=nodefault
|
||||
env CGO_CPPFLAGS=nodefault
|
||||
env GOFIPS140=latest
|
||||
|
||||
go env -changed
|
||||
# linux output like GOTOOLCHAIN='local'
|
||||
|
|
@ -17,6 +18,7 @@ stdout 'GOPROXY=''?nodefault''?'
|
|||
stdout 'GO111MODULE=''?auto''?'
|
||||
stdout 'CGO_CFLAGS=''?nodefault''?'
|
||||
stdout 'CGO_CPPFLAGS=''?nodefault''?'
|
||||
stdout 'GOFIPS140=''?latest''?'
|
||||
|
||||
go env -changed -json
|
||||
stdout '"GOTOOLCHAIN": "local"'
|
||||
|
|
@ -25,6 +27,7 @@ stdout '"GOPROXY": "nodefault"'
|
|||
stdout '"GO111MODULE": "auto"'
|
||||
stdout '"CGO_CFLAGS": "nodefault"'
|
||||
stdout '"CGO_CPPFLAGS": "nodefault"'
|
||||
stdout '"GOFIPS140": "latest"'
|
||||
|
||||
[GOOS:windows] env GOOS=linux
|
||||
[!GOOS:windows] env GOOS=windows
|
||||
|
|
@ -64,6 +67,7 @@ go env -changed
|
|||
-- a/go.env --
|
||||
GOPROXY=s
|
||||
GOAMD64=v1
|
||||
GOFIPS140=off
|
||||
|
||||
-- b/go.env --
|
||||
GOTOOLCHAIN=local
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func goamd64() int {
|
|||
}
|
||||
|
||||
func gofips140() string {
|
||||
v := envOr("GOFIPS140", defaultGOFIPS140)
|
||||
v := envOr("GOFIPS140", DefaultGOFIPS140)
|
||||
switch v {
|
||||
case "off", "latest", "inprocess", "certified":
|
||||
return v
|
||||
|
|
@ -81,7 +81,7 @@ func gofips140() string {
|
|||
return v
|
||||
}
|
||||
Error = fmt.Errorf("invalid GOFIPS140: must be off, latest, inprocess, certified, or vX.Y.Z")
|
||||
return defaultGOFIPS140
|
||||
return DefaultGOFIPS140
|
||||
}
|
||||
|
||||
// isFIPSVersion reports whether v is a valid FIPS version,
|
||||
|
|
|
|||
Loading…
Reference in New Issue