expvar: add available godoc link

Change-Id: I2db83e3c97a154f8599b4fcbceeebf1c69ee61ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/534762
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
cui fliter 2023-10-13 15:04:09 +08:00 committed by Gopher Robot
parent 0700bcfa2e
commit 74f47206cf

View File

@ -48,7 +48,7 @@ type jsonVar interface {
appendJSON(b []byte) []byte
}
// Int is a 64-bit integer variable that satisfies the Var interface.
// Int is a 64-bit integer variable that satisfies the [Var] interface.
type Int struct {
i int64
}
@ -73,7 +73,7 @@ func (v *Int) Set(value int64) {
atomic.StoreInt64(&v.i, value)
}
// Float is a 64-bit float variable that satisfies the Var interface.
// Float is a 64-bit float variable that satisfies the [Var] interface.
type Float struct {
f atomic.Uint64
}
@ -108,14 +108,14 @@ func (v *Float) Set(value float64) {
v.f.Store(math.Float64bits(value))
}
// Map is a string-to-Var map variable that satisfies the Var interface.
// Map is a string-to-Var map variable that satisfies the [Var] interface.
type Map struct {
m sync.Map // map[string]Var
keysMu sync.RWMutex
keys []string // sorted
}
// KeyValue represents a single entry in a Map.
// KeyValue represents a single entry in a [Map].
type KeyValue struct {
Key string
Value Var
@ -208,7 +208,7 @@ func (v *Map) Set(key string, av Var) {
v.m.Store(key, av)
}
// Add adds delta to the *Int value stored under the given map key.
// Add adds delta to the *[Int] value stored under the given map key.
func (v *Map) Add(key string, delta int64) {
i, ok := v.m.Load(key)
if !ok {
@ -225,7 +225,7 @@ func (v *Map) Add(key string, delta int64) {
}
}
// AddFloat adds delta to the *Float value stored under the given map key.
// AddFloat adds delta to the *[Float] value stored under the given map key.
func (v *Map) AddFloat(key string, delta float64) {
i, ok := v.m.Load(key)
if !ok {
@ -266,7 +266,7 @@ func (v *Map) Do(f func(KeyValue)) {
}
}
// String is a string variable, and satisfies the Var interface.
// String is a string variable, and satisfies the [Var] interface.
type String struct {
s atomic.Value // string
}
@ -276,8 +276,8 @@ func (v *String) Value() string {
return p
}
// String implements the Var interface. To get the unquoted string
// use Value.
// String implements the [Var] interface. To get the unquoted string
// use [String.Value].
func (v *String) String() string {
return string(v.appendJSON(nil))
}
@ -290,7 +290,7 @@ func (v *String) Set(value string) {
v.s.Store(value)
}
// Func implements Var by calling the function
// Func implements [Var] by calling the function
// and formatting the returned value using JSON.
type Func func() any