Less verbose string dump of LatestMap

The default time.Time.String() includes nanoseconds, wall-clock adjustment, etc.
Also don't include the key twice when stringizing the map itself.
This commit is contained in:
Bryan Boreham
2018-06-29 08:11:58 +00:00
parent 777360dc9e
commit c96611b13d
2 changed files with 6 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ function generate_latest_map() {
// String returns the StringLatestEntry's string representation.
func (e *${entry_type}) String() string {
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.String())
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.Format(time.RFC3339))
}
// Equal returns true if the supplied StringLatestEntry is equal to this one.
@@ -181,7 +181,7 @@ function generate_latest_map() {
func (m ${latest_map_type}) String() string {
buf := bytes.NewBufferString("{")
for _, val := range m {
fmt.Fprintf(buf, "%s: %v,\n", val.key, val)
fmt.Fprintf(buf, "%s: %s,\n", val.key, val.String())
}
fmt.Fprintf(buf, "}")
return buf.String()

View File

@@ -21,7 +21,7 @@ type stringLatestEntry struct {
// String returns the StringLatestEntry's string representation.
func (e *stringLatestEntry) String() string {
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.String())
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.Format(time.RFC3339))
}
// Equal returns true if the supplied StringLatestEntry is equal to this one.
@@ -149,7 +149,7 @@ func (m StringLatestMap) ForEach(fn func(k string, timestamp time.Time, v string
func (m StringLatestMap) String() string {
buf := bytes.NewBufferString("{")
for _, val := range m {
fmt.Fprintf(buf, "%s: %v,\n", val.key, val)
fmt.Fprintf(buf, "%s: %s,\n", val.key, val.String())
}
fmt.Fprintf(buf, "}")
return buf.String()
@@ -243,7 +243,7 @@ type nodeControlDataLatestEntry struct {
// String returns the StringLatestEntry's string representation.
func (e *nodeControlDataLatestEntry) String() string {
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.String())
return fmt.Sprintf("%v (%s)", e.Value, e.Timestamp.Format(time.RFC3339))
}
// Equal returns true if the supplied StringLatestEntry is equal to this one.
@@ -371,7 +371,7 @@ func (m NodeControlDataLatestMap) ForEach(fn func(k string, timestamp time.Time,
func (m NodeControlDataLatestMap) String() string {
buf := bytes.NewBufferString("{")
for _, val := range m {
fmt.Fprintf(buf, "%s: %v,\n", val.key, val)
fmt.Fprintf(buf, "%s: %s,\n", val.key, val.String())
}
fmt.Fprintf(buf, "}")
return buf.String()