add Tags.Equals() and Tags.Keys() methods
This commit is contained in:
parent
7b7d06fe3e
commit
92b0833444
22
cap.go
22
cap.go
@ -441,6 +441,28 @@ func (t Tags) Len() (length int) {
|
|||||||
return len(t.Bytes())
|
return len(t.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Equals compares two Tags for equality.
|
||||||
|
func (t Tags) Equals(tt Tags) bool {
|
||||||
|
if t.Count() != tt.Count() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for k, v := range t {
|
||||||
|
if vv, ok := tt[k]; !ok || v != vv {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keys returns a slice of (unsorted) tag keys.
|
||||||
|
func (t Tags) Keys() (keys []string) {
|
||||||
|
keys = make([]string, 0, t.Count())
|
||||||
|
for key := range t {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
// Count finds how many total tags that there are.
|
// Count finds how many total tags that there are.
|
||||||
func (t Tags) Count() int {
|
func (t Tags) Count() int {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user