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
}
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
}
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
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 {
}
}
-// 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 {
}
}
-// 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
}
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))
}
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