Преглед изворни кода

ptypes: Avoid assuming time.Duration is nanoseconds (#796)

It is spec'd that way, but best practice is to avoid it.
JP Sugarbroad пре 7 година
родитељ
комит
3337d28119
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      ptypes/duration.go

+ 1 - 1
ptypes/duration.go

@@ -82,7 +82,7 @@ func Duration(p *durpb.Duration) (time.Duration, error) {
 		return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
 	}
 	if p.Nanos != 0 {
-		d += time.Duration(p.Nanos)
+		d += time.Duration(p.Nanos) * time.Nanosecond
 		if (d < 0) != (p.Nanos < 0) {
 			return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
 		}