From c96611b13d2de9abc3f3f6048850c712c3391fe6 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 29 Jun 2018 08:11:58 +0000 Subject: [PATCH] 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. --- extras/generate_latest_map | 4 ++-- report/latest_map_generated.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extras/generate_latest_map b/extras/generate_latest_map index f402160efa..78d1f9f6fe 100755 --- a/extras/generate_latest_map +++ b/extras/generate_latest_map @@ -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() diff --git a/report/latest_map_generated.go b/report/latest_map_generated.go index de10afc0d8..2cad405b73 100644 --- a/report/latest_map_generated.go +++ b/report/latest_map_generated.go @@ -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()