From 80e1cd34102aa3d935e755709b5a571f3e08385e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20Nu=C3=9F?= Date: Sat, 16 Jan 2016 13:28:52 +0100 Subject: [PATCH] Lint models package --- models/points.go | 2 ++ models/time.go | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/models/points.go b/models/points.go index 394b8f6997f..355b659c2c2 100644 --- a/models/points.go +++ b/models/points.go @@ -129,6 +129,7 @@ func ParsePointsString(buf string) ([]Point, error) { return ParsePoints([]byte(buf)) } +// ParseKey returns the measurement name and tags from a point. func ParseKey(buf string) (string, Tags, error) { _, keyBuf, err := scanKey([]byte(buf), 0) tags := parseTags([]byte(buf)) @@ -1087,6 +1088,7 @@ func NewPoint(name string, tags Tags, fields Fields, time time.Time) (Point, err }, nil } +// NewPointFromBytes returns a new Point from a marshalled Point. func NewPointFromBytes(b []byte) (Point, error) { p := &point{} if err := p.UnmarshalBinary(b); err != nil { diff --git a/models/time.go b/models/time.go index 2da5076a633..9e41577742f 100644 --- a/models/time.go +++ b/models/time.go @@ -10,28 +10,27 @@ import ( ) var ( - // Maximum time that can be represented via int64 nanoseconds since the epoch. + // MaxNanoTime is the maximum time that can be represented via int64 nanoseconds since the epoch. MaxNanoTime = time.Unix(0, math.MaxInt64).UTC() - // Minumum time that can be represented via int64 nanoseconds since the epoch. + // MinNanoTime is the minumum time that can be represented via int64 nanoseconds since the epoch. MinNanoTime = time.Unix(0, math.MinInt64).UTC() - // The time is out of the representable range using int64 nanoseconds since the epoch. + // ErrTimeOutOfRange gets returned when time is out of the representable range using int64 nanoseconds since the epoch. ErrTimeOutOfRange = fmt.Errorf("time outside range %s - %s", MinNanoTime, MaxNanoTime) ) -// Safely calculate the time given. Will return error if the time is outside the +// SafeCalcTime safely calculates the time given. Will return error if the time is outside the // supported range. func SafeCalcTime(timestamp int64, precision string) (time.Time, error) { mult := GetPrecisionMultiplier(precision) if t, ok := safeSignedMult(timestamp, mult); ok { return time.Unix(0, t).UTC(), nil - } else { - return time.Time{}, ErrTimeOutOfRange } + return time.Time{}, ErrTimeOutOfRange } -// Check that a time is within the safe range. +// CheckTime checks that a time is within the safe range. func CheckTime(t time.Time) error { if t.Before(MinNanoTime) || t.After(MaxNanoTime) { return ErrTimeOutOfRange