Skip to content

Commit

Permalink
Less verbose string dump of LatestMap
Browse files Browse the repository at this point in the history
The default time.Time.String() includes nanoseconds, wall-clock adjustment, etc.
Also don't include the key twice when stringizing the map itself.
  • Loading branch information
bboreham committed Jun 29, 2018
1 parent a4d7976 commit de47a0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions extras/generate_latest_map
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -203,7 +203,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()
Expand Down
8 changes: 4 additions & 4 deletions report/latest_map_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -171,7 +171,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()
Expand Down Expand Up @@ -265,7 +265,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.
Expand Down Expand Up @@ -415,7 +415,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()
Expand Down

0 comments on commit de47a0e

Please sign in to comment.