Skip to content

Commit c9d3e7d

Browse files
committed
gopls: upgrade x/telemetry and account for new mode logic
Upgrade x/telemetry to pick up the new (on|off|local) mode logic. In this new schema, when the mode is explicitly "off" we should assume that the user doesn't want to be prompted about enabling telemetry. Update our internal logic and tests accordingly. For golang/go#63832 Change-Id: I7b9c0840c48c680110ffa84c59bce2d5249942dd Reviewed-on: https://go-review.googlesource.com/c/tools/+/542317 Reviewed-by: Peter Weinberger <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit 944d4e7) Reviewed-on: https://go-review.googlesource.com/c/tools/+/542156 Reviewed-by: Alan Donovan <[email protected]>
1 parent e985f84 commit c9d3e7d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

gopls/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ require (
77
github.com/jba/printsrc v0.2.2
88
github.com/jba/templatecheck v0.6.0
99
github.com/sergi/go-diff v1.1.0
10-
golang.org/x/mod v0.13.0
10+
golang.org/x/mod v0.14.0
1111
golang.org/x/sync v0.4.0
12-
golang.org/x/sys v0.13.0
13-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052
12+
golang.org/x/sys v0.14.0
13+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400
1414
golang.org/x/text v0.13.0
1515
golang.org/x/tools v0.14.1-0.20231026192422-8b5abd452b28
1616
golang.org/x/vuln v1.0.1

gopls/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
3030
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
3131
golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
3232
golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
33-
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
34-
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
33+
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
34+
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
3535
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
3636
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
3737
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
38-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
39-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
40-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y=
41-
golang.org/x/telemetry v0.0.0-20231011160506-788d5629a052/go.mod h1:6p4ScoNeC2dhpQ1nSSMmkZ7mEj5JQUSCyc0uExBp5T4=
38+
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
39+
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
40+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU=
41+
golang.org/x/telemetry v0.0.0-20231114163143-69313e640400/go.mod h1:P6hMdmAcoG7FyATwqSr6R/U0n7yeXNP/QXeRlxb1szE=
4242
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
4343
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
4444
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=

gopls/internal/lsp/prompt.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *Server) telemetryMode() string {
6262
if data, err := os.ReadFile(fake); err == nil {
6363
return string(data)
6464
}
65-
return "off"
65+
return "local"
6666
}
6767
return telemetry.Mode()
6868
}
@@ -95,8 +95,8 @@ func (s *Server) maybePromptForTelemetry(ctx context.Context, enabled bool) {
9595
return // prompt is disabled
9696
}
9797

98-
if s.telemetryMode() == "on" {
99-
// Telemetry is already on -- nothing to ask about.
98+
if s.telemetryMode() == "on" || s.telemetryMode() == "off" {
99+
// Telemetry is already on or explicitly off -- nothing to ask about.
100100
return
101101
}
102102

@@ -262,9 +262,9 @@ func telemetryOnMessage(linkify bool) string {
262262
263263
To disable telemetry uploading, run %s.
264264
`
265-
var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest off`"
265+
var runCmd = "`go run golang.org/x/telemetry/cmd/gotelemetry@latest local`"
266266
if linkify {
267-
runCmd = "[gotelemetry off](https://golang.org/x/telemetry/cmd/gotelemetry)"
267+
runCmd = "[gotelemetry local](https://golang.org/x/telemetry/cmd/gotelemetry)"
268268
}
269269
return fmt.Sprintf(format, runCmd)
270270
}

gopls/internal/regtest/misc/prompt_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333

3434
for _, enabled := range []bool{true, false} {
3535
t.Run(fmt.Sprintf("telemetryPrompt=%v", enabled), func(t *testing.T) {
36-
for _, initialMode := range []string{"", "off", "on"} {
36+
for _, initialMode := range []string{"", "local", "off", "on"} {
3737
t.Run(fmt.Sprintf("initial_mode=%s", initialMode), func(t *testing.T) {
3838
modeFile := filepath.Join(t.TempDir(), "mode")
3939
if initialMode != "" {
@@ -51,7 +51,7 @@ func main() {
5151
"telemetryPrompt": enabled,
5252
},
5353
).Run(t, src, func(t *testing.T, env *Env) {
54-
wantPrompt := enabled && (initialMode == "" || initialMode == "off")
54+
wantPrompt := enabled && (initialMode == "" || initialMode == "local")
5555
expectation := ShownMessageRequest(".*Would you like to enable Go telemetry?")
5656
if !wantPrompt {
5757
expectation = Not(expectation)

0 commit comments

Comments
 (0)