Source file src/cmd/go/internal/telemetrystats/telemetrystats.go

     1  // Copyright 2024 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !cmd_go_bootstrap
     6  
     7  package telemetrystats
     8  
     9  import (
    10  	"cmd/go/internal/base"
    11  	"cmd/go/internal/cfg"
    12  	"cmd/go/internal/modload"
    13  	"cmd/internal/telemetry/counter"
    14  )
    15  
    16  func Increment() {
    17  	incrementConfig()
    18  	incrementVersionCounters()
    19  }
    20  
    21  // incrementConfig increments counters for the configuration
    22  // the command is running in.
    23  func incrementConfig() {
    24  	if !modload.WillBeEnabled() {
    25  		counter.Inc("go/mode:gopath")
    26  	} else if workfile := modload.FindGoWork(base.Cwd()); workfile != "" {
    27  		counter.Inc("go/mode:workspace")
    28  	} else {
    29  		counter.Inc("go/mode:module")
    30  	}
    31  	counter.Inc("go/platform/target/goos:" + cfg.Goos)
    32  	counter.Inc("go/platform/target/goarch:" + cfg.Goarch)
    33  	switch cfg.Goarch {
    34  	case "386":
    35  		counter.Inc("go/platform/target/go386:" + cfg.GO386)
    36  	case "amd64":
    37  		counter.Inc("go/platform/target/goamd64:" + cfg.GOAMD64)
    38  	case "arm":
    39  		counter.Inc("go/platform/target/goarm:" + cfg.GOARM)
    40  	case "arm64":
    41  		counter.Inc("go/platform/target/goarm64:" + cfg.GOARM64)
    42  	case "mips":
    43  		counter.Inc("go/platform/target/gomips:" + cfg.GOMIPS)
    44  	case "ppc64":
    45  		counter.Inc("go/platform/target/goppc64:" + cfg.GOPPC64)
    46  	case "riscv64":
    47  		counter.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64)
    48  	case "wasm":
    49  		counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
    50  	}
    51  }
    52  

View as plain text