目录 搜索
archive archive/tar archive/zip bufio bufio(缓存) builtin builtin(内置包) bytes bytes(包字节) compress compress/bzip2(压缩/bzip2) compress/flate(压缩/flate) compress/gzip(压缩/gzip) compress/lzw(压缩/lzw) compress/zlib(压缩/zlib) container container/heap(容器数据结构heap) container/list(容器数据结构list) container/ring(容器数据结构ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(数据库/sql) database/sql/driver(数据库/sql/driver) debug debug/dwarf(调试/dwarf) debug/elf(调试/elf) debug/gosym(调试/gosym) debug/macho(调试/macho) debug/pe(调试/pe) debug/plan9obj(调试/plan9obj) encoding encoding(编码) encoding/ascii85(编码/ascii85) encoding/asn1(编码/asn1) encoding/base32(编码/base32) encoding/base64(编码/base64) encoding/binary(编码/binary) encoding/csv(编码/csv) encoding/gob(编码/gob) encoding/hex(编码/hex) encoding/json(编码/json) encoding/pem(编码/pem) encoding/xml(编码/xml) errors errors(错误) expvar expvar flag flag(命令行参数解析flag包) fmt fmt go go/ast(抽象语法树) go/build go/constant(常量) go/doc(文档) go/format(格式) go/importer go/parser go/printer go/scanner(扫描仪) go/token(令牌) go/types(类型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(图像) image/color(颜色) image/color/palette(调色板) image/draw(绘图) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系统) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路径) plugin plugin(插件) reflect reflect(反射) regexp regexp(正则表达式) regexp/syntax runtime runtime(运行时) runtime/debug(调试) runtime/internal/sys runtime/pprof runtime/race(竞争) runtime/trace(执行追踪器) sort sort(排序算法) strconv strconv(转换) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系统调用) testing testing(测试) testing/iotest testing/quick text text/scanner(扫描文本) text/tabwriter text/template(定义模板) text/template/parse time time(时间戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "expvar"

  • 概述

  • 索引

概述

软件包 expvar 为公共变量提供了标准化接口,如服务器中的操作计数器。它以 JSON 格式在 /debug/vars 中通过 HTTP 公开这些变量。

设置或修改这些公共变量的操作是原子操作。

除了添加 HTTP 处理程序之外,该程序包还会注册以下变量:

cmdline   os.Args
memstats  runtime.Memstats

该包有时只是为了注册 HTTP 处理程序和上述变量的副作用而导入。要以这种方式使用,请将此程序包链接到您的程序中:

import _ "expvar"

索引

  • func Do(f func(KeyValue))

  • func Handler() http.Handler

  • func Publish(name string, v Var)

  • type Float

  • func NewFloat(name string) *Float

  • func (v *Float) Add(delta float64)

  • func (v *Float) Set(value float64)

  • func (v *Float) String() string

  • func (v *Float) Value() float64

  • type Func

  • func (f Func) String() string

  • func (f Func) Value() interface{}

  • type Int

  • func NewInt(name string) *Int

  • func (v *Int) Add(delta int64)

  • func (v *Int) Set(value int64)

  • func (v *Int) String() string

  • func (v *Int) Value() int64

  • type KeyValue

  • type Map

  • func NewMap(name string) *Map

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

  • func (v *Map) AddFloat(key string, delta float64)

  • func (v *Map) Do(f func(KeyValue))

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

  • func (v *Map) Init() *Map

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

  • func (v *Map) String() string

  • type String

  • func NewString(name string) *String

  • func (v *String) Set(value string)

  • func (v *String) String() string

  • func (v *String) Value() string

  • type Var

  • func Get(name string) Var

包文件

expvar.go

func Do

func Do(f func(KeyValue))

对每个导出的变量都调用 f 。全局变量映射在迭代期间被锁定,但现有条目可能会同时更新。

func Handler

func Handler() http.Handler

处理程序返回expvar HTTP处理程序。

这只需要将处理程序安装在非标准位置。

func Publish

func Publish(name string, v Var)

发布声明一个命名的导出变量。这应该在创建其变量时从包的 init 函数中调用。如果名称已经注册,那么这将会 log.Panic。

type Float

Float 是一个满足 Var 接口的64位浮点型变量。

type Float struct {        // 包含已过滤或未导出的字段}

func NewFloat

func NewFloat(name string) *Float

func (*Float) Add

func (v *Float) Add(delta float64)

添加将增量添加到v。

func (*Float) Set

func (v *Float) Set(value float64)

将v设置为值。

func (*Float) String

func (v *Float) String() string

func (*Float) Value

func (v *Float) Value() float64

type Func

Func 通过调用函数并使用 JSON 格式化返回的值来实现 Var。

type Func func() interface{}

func (Func) String

func (f Func) String() string

func (Func) Value

func (f Func) Value() interface{}

type Int

Int 是一个满足 Var 接口的64位整数变量。

type Int struct {        // 包含已过滤或未导出的字段}

func NewInt

func NewInt(name string) *Int

func (*Int) Add

func (v *Int) Add(delta int64)

func (*Int) Set

func (v *Int) Set(value int64)

func (*Int) String

func (v *Int) String() string

func (*Int) Value

func (v *Int) Value() int64

type KeyValue

KeyValue 表示 Map 中的单个条目。

type KeyValue struct {
        Key   string
        Value Var}

type Map

Map 是一个满足 Var 接口的字符串到 Var 映射变量。

type Map struct {        // 包含已过滤或未导出的字段}

func NewMap

func NewMap(name string) *Map

func (*Map) Add

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

添加将增量添加到存储在给定映射键下的 *Int 值。

func (*Map) AddFloat

func (v *Map) AddFloat(key string, delta float64)

AddFloat 将增量添加到存储在给定映射关键字下的 *Float值。

func (*Map) Do

func (v *Map) Do(f func(KeyValue))

请为地图中的每个条目调用 f 。迭代期间地图被锁定,但现有条目可能会同时更新。

func (*Map) Get

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

func (*Map) Init

func (v *Map) Init() *Map

Init 从地图上删除所有密钥。

func (*Map) Set

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

func (*Map) String

func (v *Map) String() string

type String

字符串是一个字符串变量,并且满足 Var 接口。

type String struct {        // 包含已过滤或未导出的字段}

func NewString

func NewString(name string) *String

func (*String) Set

func (v *String) Set(value string)

func (*String) String

func (v *String) String() string

字符串实现 Val 接口。要获取未加引号的字符串,请使用 Value。

func (*String) Value

func (v *String) Value() string

type Var

Var是所有导出变量的抽象类型。

type Var interface {        // String返回变量的有效JSON值。        // 具有不返回有效JSON的String方法的类型        // (例如time.Time)不能用作Var。        String() string}

func Get

func Get(name string) Var

获取一个命名的导出变量。如果名称尚未注册,则返回 nil。

上一篇: 下一篇: