To my surprise, this compiled
fmt.Println(time.Second * time.Second)
The result is nonsense
277777h46m40s
It doesn't make any sense to multiply a duration by duration and get another duration.
What's going on?
To my surprise, this compiled
fmt.Println(time.Second * time.Second)
The result is nonsense
277777h46m40s
It doesn't make any sense to multiply a duration by duration and get another duration.
What's going on?
The Duration type is simply an int64 representing the duration as a nanosecond count
type Duration int64
A Duration represents the elapsed time between two instants as an int64 nanosecond count.
So multiplying one duration by another gives the result of multiplying the number of nanoseconds in each. In my example, this gives a billion billion nanoseconds, or 277777h46m40s
. Nonsense, but well-defined!