瀏覽代碼

Better documentation from Michael's suggestions

Niko Kovacevic 5 年之前
父節點
當前提交
c5898ed816
共有 2 個文件被更改,包括 5 次插入2 次删除
  1. 2 2
      pkg/prom/result.go
  2. 3 0
      pkg/util/mapper/mapper.go

+ 2 - 2
pkg/prom/result.go

@@ -224,7 +224,7 @@ func (qr *QueryResult) GetString(field string) (string, error) {
 
 	strField, ok := f.(string)
 	if !ok {
-		return "", fmt.Errorf("'%s' field is improperly formatted", field)
+		return "", fmt.Errorf("'%s' field is improperly formatted and cannot be converted to string", field)
 	}
 
 	return strField, nil
@@ -242,7 +242,7 @@ func (qr *QueryResult) GetStrings(fields ...string) (map[string]string, error) {
 
 		value, ok := f.(string)
 		if !ok {
-			return nil, fmt.Errorf("'%s' field is improperly formatted", field)
+			return nil, fmt.Errorf("'%s' field is improperly formatted and cannot be converted to string", field)
 		}
 
 		values[field] = value

+ 3 - 0
pkg/util/mapper/mapper.go

@@ -503,6 +503,9 @@ const (
 	secsPerDay  = 86400.0
 )
 
+// durationString converts duration to a string of the form "4d", "4h", "4m", or "4s" if
+// the number of seconds in the string is evenly divisible into an integer number of
+// days, hours, minutes, or seconds respectively.
 func durationString(duration time.Duration) string {
 	durSecs := int64(duration.Seconds())