package godebug
Import Path
internal/godebug (on go.dev)
Dependency Relation
imports 5 packages, and imported by 7 packages
Involved Source Files
Package godebug makes the settings in the $GODEBUG environment variable
available to other packages. These settings are often used for compatibility
tweaks, when we need to change a default behavior but want to let users
opt back in to the original. For example GODEBUG=http2server=0 disables
HTTP/2 support in the net/http server.
In typical usage, code should declare a Setting as a global
and then call Value each time the current setting value is needed:
var http2server = godebug.New("http2server")
func ServeConn(c net.Conn) {
if http2server.Value() == "0" {
disallow HTTP/2
...
}
...
}
Each time a non-default setting causes a change in program behavior,
code should call [Setting.IncNonDefault] to increment a counter that can
be reported by [runtime/metrics.Read].
Note that counters used with IncNonDefault must be added to
various tables in other packages. See the [Setting.IncNonDefault]
documentation for details.
Package-Level Type Names (total 4, in which 1 is exported)
A Setting is a single setting in the $GODEBUG environment variable.
name string
once sync.Once
setting *setting
setting.info *godebugs.Info
setting.nonDefault atomic.Uint64
setting.nonDefaultOnce sync.Once
setting.value atomic.Pointer[value]
IncNonDefault increments the non-default behavior counter
associated with the given setting.
This counter is exposed in the runtime/metrics value
/godebug/non-default-behavior/<name>:events.
Note that Value must be called at least once before IncNonDefault.
Name returns the name of the setting.
String returns a printable form for the setting: name=value.
Undocumented reports whether this is an undocumented setting.
Value returns the current value for the GODEBUG setting s.
Value maintains an internal cache that is synchronized
with changes to the $GODEBUG environment variable,
making Value efficient to call as frequently as needed.
Clients should therefore typically not attempt their own
caching of Value's result.
(*Setting) register()
*Setting : fmt.Stringer
*Setting : context.stringer
*Setting : runtime.stringer
func New(name string) *Setting
var internal/intern.intern *Setting
var crypto/tls.tlsmaxrsasize *Setting
var crypto/x509.x509sha1 *Setting
var crypto/x509.x509usefallbackroots *Setting
var math/rand.randautoseed *Setting
var mime/multipart.multipartFiles *Setting
var mime/multipart.multipartMaxHeaders *Setting
var mime/multipart.multipartMaxParts *Setting
var net.multipathtcp *Setting
var net.netdns *Setting
var net/http.http2client *Setting
var net/http.http2server *Setting
Package-Level Functions (total 10, in which 1 is exported)
New returns a new Setting for the $GODEBUG setting with the given name.
GODEBUGs meant for use by end users must be listed in ../godebugs/table.go,
which is used for generating and checking various documentation.
If the name is not listed in that table, New will succeed but calling Value
on the returned Setting will panic.
To disable that panic for access to an undocumented setting,
prefix the name with a #, as in godebug.New("#gofsystrace").
The # is a signal to New but not part of the key used in $GODEBUG.
Package-Level Variables (total 4, none are exported)
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |