]> Cypherpunks repositories - gostls13.git/commit
time: parse 1us in Nanoseconds example
authorAlberto Donizetti <alb.donizetti@gmail.com>
Sun, 24 Feb 2019 21:48:46 +0000 (22:48 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Tue, 26 Feb 2019 17:22:58 +0000 (17:22 +0000)
commitc0101b1961299ce6d13fac3c1dd13d3aea22b276
tree205d7abeb734bc73d0ef8fdd9736cc32be63d233
parentb5a68a9e414dc1d412d623f80c54aafe3ada0f14
time: parse 1us in Nanoseconds example

The example for Nanoseconds() currently reads:

  ns, _ := time.ParseDuration("1000ns")
  fmt.Printf("one microsecond has %d nanoseconds.", ns.Nanoseconds())

which is not terribly interesting: it seems obvious that parsing
"1000ns" and then calling Nanoseconds() will print 1000. The mention
of microseconds in the text suggests that the author's intention was,
instead, to write something like this:

  u, _ := time.ParseDuration("1us")

i.e. build a time value by parsing 1 microsecond, and then print the
value in nanoseconds. Change the example to do this.

Change-Id: I4ddb123f0935a12cda3b5d6f1ca919bfcd6383d6
Reviewed-on: https://go-review.googlesource.com/c/163622
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/time/example_test.go