mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
use mapToString where possible
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package report
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/ugorji/go/codec"
|
||||
@@ -109,22 +107,7 @@ func (c EdgeMetadatas) ForEach(fn func(k string, v EdgeMetadata)) {
|
||||
}
|
||||
|
||||
func (c EdgeMetadatas) String() string {
|
||||
keys := []string{}
|
||||
if c.psMap == nil {
|
||||
c = EmptyEdgeMetadatas
|
||||
}
|
||||
for _, k := range c.psMap.Keys() {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
buf := bytes.NewBufferString("{")
|
||||
for _, key := range keys {
|
||||
val, _ := c.psMap.Lookup(key)
|
||||
fmt.Fprintf(buf, "%s: %v, ", key, val)
|
||||
}
|
||||
fmt.Fprintf(buf, "}")
|
||||
return buf.String()
|
||||
return mapToString(c.psMap)
|
||||
}
|
||||
|
||||
// DeepEqual tests equality with other Counters
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package report
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
||||
"github.com/ugorji/go/codec"
|
||||
"github.com/weaveworks/ps"
|
||||
@@ -109,22 +106,7 @@ func (s Sets) Copy() Sets {
|
||||
}
|
||||
|
||||
func (s Sets) String() string {
|
||||
if s.psMap == nil {
|
||||
s = EmptySets
|
||||
}
|
||||
keys := []string{}
|
||||
for _, k := range s.psMap.Keys() {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
buf := bytes.NewBufferString("{")
|
||||
for _, key := range keys {
|
||||
val, _ := s.psMap.Lookup(key)
|
||||
fmt.Fprintf(buf, "%s: %v, ", key, val)
|
||||
}
|
||||
fmt.Fprintf(buf, "}")
|
||||
return buf.String()
|
||||
return mapToString(s.psMap)
|
||||
}
|
||||
|
||||
// DeepEqual tests equality with other Sets
|
||||
|
||||
Reference in New Issue
Block a user