]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: print the proper error message for setting telemetry vars
authorMichael Matloob <matloob@golang.org>
Wed, 28 Aug 2024 15:15:32 +0000 (11:15 -0400)
committerMichael Matloob <matloob@golang.org>
Wed, 28 Aug 2024 16:55:45 +0000 (16:55 +0000)
For #68960

Change-Id: I5495b3d45ad3817d7edf6336a5e24a331d5cf8d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/609115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
src/cmd/go/internal/envcmd/env.go
src/cmd/go/testdata/script/telemetry.txt

index f19577c4df1875600cf0f25d5d9c85e0a8a259ee..a99b2ed140f45769ec4baff1268745cd287ef4a3 100644 (file)
@@ -590,7 +590,7 @@ func getOrigEnv(key string) string {
 
 func checkEnvWrite(key, val string) error {
        switch key {
-       case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION":
+       case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION", "GOTELEMETRY", "GOTELEMETRYDIR":
                return fmt.Errorf("%s cannot be modified", key)
        case "GOENV", "GODEBUG":
                return fmt.Errorf("%s can only be set using the OS environment", key)
index e9aa0f108590374c63c31e4c47749f66139c92b6..838e743d50ff93f2db8904f357108c9046cf9264 100644 (file)
@@ -46,6 +46,6 @@ go env
 stdout 'GOTELEMETRY=''?on''?'
 stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?'
 ! go env -w GOTELEMETRY=off
-stderr '^go: unknown go command variable GOTELEMETRY$'
+stderr '^go: GOTELEMETRY cannot be modified$'
 ! go env -w GOTELEMETRYDIR=foo
-stderr '^go: unknown go command variable GOTELEMETRYDIR$'
\ No newline at end of file
+stderr '^go: GOTELEMETRYDIR cannot be modified$'
\ No newline at end of file