From f38e9d32cb4dc3b37f4c77d117b4d2f1b27523bb Mon Sep 17 00:00:00 2001 From: JP Sugarbroad Date: Tue, 5 Feb 2019 14:08:34 -0800 Subject: [PATCH] Avoid assuming time.Duration is nanoseconds It is spec'd that way, but best practice is to avoid it. --- ptypes/duration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ptypes/duration.go b/ptypes/duration.go index 65cb0f8eb5..26d1ca2fb5 100644 --- a/ptypes/duration.go +++ b/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) }