From 2f87c439eab82861522496ca32769a8e3ad4ccc0 Mon Sep 17 00:00:00 2001 From: ZhangJian He Date: Mon, 8 Apr 2024 20:26:51 +0800 Subject: [PATCH] refactor: rename PrecisionType to Precision (#69) Signed-off-by: ZhangJian He --- opengemini/point.go | 12 ++++++------ opengemini/point_test.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/opengemini/point.go b/opengemini/point.go index 1568056..33d5429 100644 --- a/opengemini/point.go +++ b/opengemini/point.go @@ -8,7 +8,7 @@ import ( ) const ( - PrecisionNanoSecond PrecisionType = iota + PrecisionNanoSecond Precision = iota PrecisionMicrosecond PrecisionMillisecond PrecisionSecond @@ -16,9 +16,9 @@ const ( PrecisionHour ) -type PrecisionType int +type Precision int -func (p PrecisionType) String() string { +func (p Precision) String() string { switch p { case PrecisionNanoSecond: return "PrecisionNanoSecond" @@ -39,7 +39,7 @@ func (p PrecisionType) String() string { type Point struct { Measurement string // Precision Timestamp precision ,default value is PrecisionNanoSecond - Precision PrecisionType + Precision Precision Time time.Time Tags map[string]string Fields map[string]interface{} @@ -63,7 +63,7 @@ func (p *Point) SetTime(t time.Time) { p.Time = t } -func (p *Point) SetPrecision(precision PrecisionType) { +func (p *Point) SetPrecision(precision Precision) { p.Precision = precision } @@ -255,7 +255,7 @@ func (enc *LineProtocolEncoder) BatchEncode(bp *BatchPoints) error { return nil } -func formatTimestamp(t time.Time, p PrecisionType) string { +func formatTimestamp(t time.Time, p Precision) string { switch p { case PrecisionNanoSecond: return strconv.FormatInt(t.UnixNano(), 10) diff --git a/opengemini/point_test.go b/opengemini/point_test.go index 0e42790..84ac4fb 100644 --- a/opengemini/point_test.go +++ b/opengemini/point_test.go @@ -71,7 +71,7 @@ func TestPointEncode(t *testing.T) { func TestFormatTimestamp(t *testing.T) { testTime := time.Date(2023, 12, 1, 12, 32, 18, 132363612, time.UTC) tests := []struct { - precision PrecisionType + precision Precision timestamp string }{ {