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.
Operations to set or modify these public variables are atomic.
Index ¶
- Constants
- func Memstats() runtime.MemStats
- type Float64
- type Func
- type Int
- type KeyValue
- type String
- type Var
- type Vars
- func (v *Vars) Do(f func(KeyValue) error) error
- func (v *Vars) Forward(dst *Vars, keyPrefix string) error
- func (v *Vars) Get(name string) Var
- func (v *Vars) Handler(w http.ResponseWriter, r *http.Request)
- func (v *Vars) Publish(name string, val Var) error
- func (v *Vars) WriteTo(wr io.Writer) (size int64, err error)
Constants ¶
const (
DefaultVarsRoute = "/debug/vars"
)
Constants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is a 64-bit float variable that satisfies the Var interface.
type Func ¶
type Func func() interface{}
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 String ¶
type String struct {
// contains filtered or unexported fields
}
String is a string variable, and satisfies the Var interface.
type Var ¶
type Var interface { // String returns a valid JSON value for the variable. // Types with String methods that do not return valid JSON // (such as time.Time) must not be used as a Var. String() string }
Var is an abstract type for all exported variables.
type Vars ¶
type Vars struct {
// contains filtered or unexported fields
}
Vars is a collection of expvars.
func (*Vars) Do ¶
Do calls f for each exported variable. The global variable map is locked during the iteration, but existing entries may be concurrently updated.
func (*Vars) Forward ¶ added in v1.20210221.5
Forward forwards the vars contained in this set to another set with a given key prefix.
func (*Vars) Get ¶
Get retrieves a named exported variable. It returns nil if the name has not been registered.
func (*Vars) Handler ¶
func (v *Vars) Handler(w http.ResponseWriter, r *http.Request)
Handler returns an http.HandlerFunc that renders the vars as json.