Imports #
"encoding/json"
"internal/godebug"
"log"
"math"
"net/http"
"os"
"runtime"
"slices"
"strconv"
"sync"
"sync/atomic"
"unicode/utf8"
"encoding/json"
"internal/godebug"
"log"
"math"
"net/http"
"os"
"runtime"
"slices"
"strconv"
"sync"
"sync/atomic"
"unicode/utf8"
All published variables.
var vars Map
Func implements [Var] by calling the function and formatting the returned value using JSON.
type Func func() any
Var is an abstract type for all exported variables.
type Var interface {
String() string
}
type jsonVar interface {
appendJSON(b []byte) []byte
}
Float is a 64-bit float variable that satisfies the [Var] interface.
type Float struct {
f atomic.Uint64
}
Int is a 64-bit integer variable that satisfies the [Var] interface.
type Int struct {
i atomic.Int64
}
KeyValue represents a single entry in a [Map].
type KeyValue struct {
Key string
Value Var
}
Map is a string-to-Var map variable that satisfies the [Var] interface.
type Map struct {
m sync.Map
keysMu sync.RWMutex
keys []string
}
String is a string variable, and satisfies the [Var] interface.
type String struct {
s atomic.Value
}
func (v *Int) Add(delta int64)
Add adds delta to v.
func (v *Float) Add(delta float64)
Add adds delta to the *[Int] value stored under the given map key.
func (v *Map) Add(key string, delta int64)
AddFloat adds delta to the *[Float] value stored under the given map key.
func (v *Map) AddFloat(key string, delta float64)
Delete deletes the given key from the map.
func (v *Map) Delete(key string)
Do calls f for each exported variable. The global variable map is locked during the iteration, but existing entries may be concurrently updated.
func Do(f func(KeyValue))
Do calls f for each entry in the map. The map is locked during the iteration, but existing entries may be concurrently updated.
func (v *Map) Do(f func(KeyValue))
Get retrieves a named exported variable. It returns nil if the name has not been registered.
func Get(name string) Var
func (v *Map) Get(key string) Var
Handler returns the expvar HTTP Handler. This is only needed to install the handler in a non-standard location.
func Handler() http.Handler
Init removes all keys from the map.
func (v *Map) Init() *Map
func NewFloat(name string) *Float
func NewInt(name string) *Int
func NewMap(name string) *Map
func NewString(name string) *String
Publish declares a 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.Panic.
func Publish(name string, v Var)
func (v *String) Set(value string)
func (v *Map) Set(key string, av Var)
Set sets v to value.
func (v *Float) Set(value float64)
func (v *Int) Set(value int64)
func (f Func) String() string
func (v *Float) String() string
String implements the [Var] interface. To get the unquoted string use [String.Value].
func (v *String) String() string
func (v *Int) String() string
func (v *Map) String() string
func (f Func) Value() any
func (v *Int) Value() int64
func (v *String) Value() string
func (v *Float) Value() float64
addKey updates the sorted list of keys in v.keys.
func (v *Map) addKey(key string)
func (v *Map) appendJSON(b []byte) []byte
func (v *Float) appendJSON(b []byte) []byte
func (v *Int) appendJSON(b []byte) []byte
func (v *String) appendJSON(b []byte) []byte
func (v *Map) appendJSONMayExpand(b []byte, expand bool) []byte
TODO: Use json.appendString instead.
func appendJSONQuote(b []byte, s string) []byte
func cmdline() any
func expvarHandler(w http.ResponseWriter, r *http.Request)
func init()
func memstats() any
Generated with Arrow