Documentation
ยถ
Overview ยถ
Package expvar provides a standardized interface to public variables, such as operation counters in servers. It exposes these variables via HTTP at /debug/vars in JSON format. As of Go 1.22, the /debug/vars request must use GET.
Operations to set or modify these public variables are atomic.
In addition to adding the HTTP handler, this package registers the following variables:
cmdline os.Args memstats runtime.Memstats
The package is sometimes only imported for the side effect of registering its HTTP handler and the above variables. To use it this way, link this package into your program:
import _ "expvar"
Index ยถ
Constants ยถ
This section is empty.
Variables ยถ
This section is empty.
Functions ยถ
func Do ยถ
func Do(f func(KeyValue))
Do calls f for each exported variable. The global variable map is locked during the iteration, but existing entries may be concurrently updated.
Types ยถ
type Float ยถ
type Float struct {
// contains filtered or unexported fields
}
Float is a 64-bit float variable that satisfies the Var interface.
type Func ยถ
type Func func() any
Func implements Var by calling the function and formatting the returned value using JSON.
type Int ยถ
type Int struct {
// contains filtered or unexported fields
}
Int is a 64-bit integer variable that satisfies the Var interface.
type Map ยถ
type Map struct {
// contains filtered or unexported fields
}
Map is a string-to-Var map variable that satisfies the Var interface.
type String ยถ
type String struct {
// contains filtered or unexported fields
}
String is a string variable, and satisfies the Var interface.
func (*String) String ยถ
String implements the Var interface. To get the unquoted string use String.Value.