Go Home Page
The Go Programming Language

Package expvar

import "expvar"

The expvar package 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.

Package files

expvar.go

func Iter

func Iter() <-chan KeyValue

func Publish

func Publish(name string, v Var)

Publish declares an named exported variable. This should be called from a package's init function when it creates its Vars. If the name is already registered then this will log.Crash.

func RemoveAll

func RemoveAll()

RemoveAll removes all exported variables. This is for tests; don't call this on a real server.

type Int

Int is a 64-bit integer variable, and satisfies the Var interface.

type Int struct {
    // contains unexported fields
}

func NewInt

func NewInt(name string) *Int

func (*Int) Add

func (v *Int) Add(delta int64)

func (*Int) String

func (v *Int) String() string

type IntFunc

IntFunc wraps a func() int64 to create a value that satisfies the Var interface. The function will be called each time the Var is evaluated.

type IntFunc func() int64

func (IntFunc) String

func (v IntFunc) String() string

type KeyValue

KeyValue represents a single entry in a Map.

type KeyValue struct {
    Key   string
    Value Var
}

type Map

Map is a string-to-Var map variable, and satisfies the Var interface.

type Map struct {
    // contains unexported fields
}

func NewMap

func NewMap(name string) *Map

func (*Map) Add

func (v *Map) Add(key string, delta int64)

func (*Map) Get

func (v *Map) Get(key string) Var

func (*Map) Init

func (v *Map) Init() *Map

func (*Map) Iter

func (v *Map) Iter() <-chan KeyValue

func (*Map) Set

func (v *Map) Set(key string, av Var)

func (*Map) String

func (v *Map) String() string

type String

String is a string variable, and satisfies the Var interface.

type String struct {
    // contains unexported fields
}

func NewString

func NewString(name string) *String

func (*String) Set

func (v *String) Set(value string)

func (*String) String

func (v *String) String() string

type Var

Var is an abstract type for all exported variables.

type Var interface {
    String() string
}

func Get

func Get(name string) Var

Get retrieves a named exported variable.