% go doc time.Second const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Millisecond Minute = 60 * Second Hour = 60 * Minute ) Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions.
To count the number of units in a Duration, divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s % On Wed, Apr 5, 2017 at 9:42 AM, Sebastien Binet <seb.bi...@gmail.com> wrote: > > > On Wed, Apr 5, 2017 at 5:37 PM, <mpboom2...@gmail.com> wrote: > >> Hello, >> >> I just saw this example: >> >> time.Sleep(n * time.Second) >> >> I then looked at http://golang.org/pkg/time, but i couldn't find out >> what time.Second is... It is not a function, not a method, not a type... >> >> What is this??? >> > > it's a Duration: > https://golang.org/pkg/time/#Duration > > -s > > >> Thank you for your time! >> >> - Mark >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.