Source file src/cmd/vendor/golang.org/x/telemetry/mode.go
1 // Copyright 2023 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 package telemetry 6 7 import "golang.org/x/telemetry/internal/telemetry" 8 9 // Mode returns the current telemetry mode. 10 // 11 // The telemetry mode is a global value that controls both the local collection 12 // and uploading of telemetry data. Possible mode values are: 13 // - "on": both collection and uploading is enabled 14 // - "local": collection is enabled, but uploading is disabled 15 // - "off": both collection and uploading are disabled 16 // 17 // When mode is "on", or "local", telemetry data is written to the local file 18 // system and may be inspected with the [gotelemetry] command. 19 // 20 // If an error occurs while reading the telemetry mode from the file system, 21 // Mode returns the default value "local". 22 // 23 // [gotelemetry]: https://pkg.go.dev/golang.org/x/telemetry/cmd/gotelemetry 24 func Mode() string { 25 mode, _ := telemetry.Default.Mode() 26 return mode 27 } 28 29 // SetMode sets the global telemetry mode to the given value. 30 // 31 // See the documentation of [Mode] for a description of the supported mode 32 // values. 33 // 34 // An error is returned if the provided mode value is invalid, or if an error 35 // occurs while persisting the mode value to the file system. 36 func SetMode(mode string) error { 37 return telemetry.Default.SetMode(mode) 38 } 39