Commit 9c4295b5 authored by Rob Pike's avatar Rob Pike

time: print zero duration as 0s, not 0

There should be a unit, and s is the SI unit name, so use that.
The other obvious possibility is ns (nanosecond), but the fact
that durations are measured in nanoseconds is an internal detail.

Fixes #14058.

Change-Id: Id1f8f3c77088224d9f7cd643778713d5cc3be5d9
Reviewed-on: https://go-review.googlesource.com/22357Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent a33e9cf7
......@@ -476,7 +476,7 @@ func (d Duration) String() string {
w--
switch {
case u == 0:
return "0"
return "0s"
case u < uint64(Microsecond):
// print nanoseconds
prec = 0
......
......@@ -533,7 +533,7 @@ var durationTests = []struct {
str string
d Duration
}{
{"0", 0},
{"0s", 0},
{"1ns", 1 * Nanosecond},
{"1.1µs", 1100 * Nanosecond},
{"2.2ms", 2200 * Microsecond},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment