move kv to label

This commit is contained in:
2020-11-01 11:36:48 +03:00
parent 50183d8ae2
commit 4f91a55f2f
9 changed files with 28 additions and 22 deletions

63
output/label/kv.go Normal file
View File

@@ -0,0 +1,63 @@
package label
import (
"fmt"
"strings"
)
var (
_ fmt.Stringer = KeyValue{}
_ fmt.Stringer = KeyValues{}
)
type KeyValues []KeyValue
func (kv KeyValues) String() string {
s := make([]string, len(kv))
for i, v := range kv {
s[i] = v.String()
}
return strings.Join(s, ", ")
}
type KeyValue struct {
Key Key
Value Value
}
func (k KeyValue) String() string {
return string(k.Key) + "=\"" + k.Value.String() + "\""
}
func Any(k string, v interface{}) KeyValue {
return Key(k).Any(v)
}
func Bool(k string, v bool) KeyValue {
return Key(k).Bool(v)
}
func Int(k string, v int) KeyValue {
return Key(k).Int(v)
}
func Int64(k string, v int64) KeyValue {
return Key(k).Int64(v)
}
func Uint(k string, v uint) KeyValue {
return Key(k).Uint(v)
}
func Uint64(k string, v uint64) KeyValue {
return Key(k).Uint64(v)
}
func Float64(k string, v float64) KeyValue {
return Key(k).Float64(v)
}
func String(k string, v string) KeyValue {
return Key(k).String(v)
}