godebug

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

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
		...
	}
	...
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Setting

type Setting struct {
	// contains filtered or unexported fields
}

A Setting is a single setting in the $GODEBUG environment variable.

func New

func New(name string) *Setting

New returns a new Setting for the $GODEBUG setting with the given name.

func (*Setting) Name

func (s *Setting) Name() string

Name returns the name of the setting.

func (*Setting) String

func (s *Setting) String() string

String returns a printable form for the setting: name=value.

func (*Setting) Value

func (s *Setting) Value() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL