diff --git a/model/samplevalue.go b/model/samplevalue.go index 72445cc..eb8dd3a 100644 --- a/model/samplevalue.go +++ b/model/samplevalue.go @@ -15,6 +15,7 @@ package model import ( "fmt" + "strconv" ) // A SampleValue is a representation of a value for a given sample at a given @@ -28,9 +29,9 @@ func (v SampleValue) Equal(o SampleValue) bool { // MarshalJSON implements json.Marshaler. func (v SampleValue) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf(`"%f"`, v)), nil + return []byte(fmt.Sprintf(`"%s"`, v)), nil } func (v SampleValue) String() string { - return fmt.Sprint(float64(v)) + return strconv.FormatFloat(float64(v), 'f', -1, 64) } diff --git a/model/timestamp.go b/model/timestamp.go index e0c6dd4..4c8fcf8 100644 --- a/model/timestamp.go +++ b/model/timestamp.go @@ -14,7 +14,8 @@ package model import ( - "fmt" + "strconv" + native_time "time" ) @@ -81,7 +82,7 @@ func (t Timestamp) UnixNano() int64 { // String returns a string representation of the timestamp. func (t Timestamp) String() string { - return fmt.Sprintf("%f", float64(t)/float64(second)) + return strconv.FormatFloat(float64(t)/float64(second), 'f', -1, 64) } func (t Timestamp) MarshalJSON() ([]byte, error) {