Skip to content

Commit fe63d48

Browse files
committed
cmd/go: print the proper error message for setting telemetry vars
For #68960 Change-Id: I5495b3d45ad3817d7edf6336a5e24a331d5cf8d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/609115 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sam Thanawalla <[email protected]>
1 parent e126129 commit fe63d48

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cmd/go/internal/envcmd/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func getOrigEnv(key string) string {
590590

591591
func checkEnvWrite(key, val string) error {
592592
switch key {
593-
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION":
593+
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION", "GOTELEMETRY", "GOTELEMETRYDIR":
594594
return fmt.Errorf("%s cannot be modified", key)
595595
case "GOENV", "GODEBUG":
596596
return fmt.Errorf("%s can only be set using the OS environment", key)

src/cmd/go/testdata/script/telemetry.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ go env
4646
stdout 'GOTELEMETRY=''?on''?'
4747
stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?'
4848
! go env -w GOTELEMETRY=off
49-
stderr '^go: unknown go command variable GOTELEMETRY$'
49+
stderr '^go: GOTELEMETRY cannot be modified$'
5050
! go env -w GOTELEMETRYDIR=foo
51-
stderr '^go: unknown go command variable GOTELEMETRYDIR$'
51+
stderr '^go: GOTELEMETRYDIR cannot be modified$'

0 commit comments

Comments
 (0)