Skip to content

Commit a55edb7

Browse files
committed
cmd/go: add telemetry for a predefined set of GOROOT values
For #58894 Change-Id: Ia30a3a1a9c7b611f55701956c08caa967634cd5a Reviewed-on: https://go-review.googlesource.com/c/go/+/586138 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sam Thanawalla <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 8096433 commit a55edb7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/cmd/go/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ func main() {
124124
fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", cfg.GOROOT)
125125
os.Exit(2)
126126
}
127+
switch strings.ToLower(cfg.GOROOT) {
128+
case "/usr/local/go": // Location recommended for installation on Linux and Darwin and used by Mac installer.
129+
telemetry.Inc("go/goroot:usr-local-go")
130+
case "/usr/lib/go": // A typical location used by Linux package managers.
131+
telemetry.Inc("go/goroot:usr-lib-go")
132+
case "/usr/lib/golang": // Another typical location used by Linux package managers.
133+
telemetry.Inc("go/goroot:usr-lib-golang")
134+
case `c:\program files\go`: // Location used by Windows installer.
135+
telemetry.Inc("go/goroot:program-files-go")
136+
case `c:\program files (x86)\go`: // Location used by 386 Windows installer on amd64 platform.
137+
telemetry.Inc("go/goroot:program-files-x86-go")
138+
default:
139+
telemetry.Inc("go/goroot:other")
140+
}
127141

128142
// Diagnose common mistake: GOPATH==GOROOT.
129143
// This setting is equivalent to not setting GOPATH at all,

0 commit comments

Comments
 (0)