time.Duration is a count of nanoseconds, and time.Millisecond is a constant that represents the number of nanoseconds in a millisecond.
The idea of storing this information as just a regular Int64 bothers me after spending so much time in type system nirvana.
Its not a regular int64, its a distinct named type (Duration) where int64 is the underyling time. I'm still getting familiar with Go -- and don't have it on the machine I'm using at the moment -- but from the docs named types are incompatible with other named types with the same underlying types in numerous contexts, but it looks like one place where named types are leaky abstractions is their interaction with operators.
package main
import (
"time"
"fmt"
)
func ident(x int64) int64 {
return x
}
func main() {
t := time.Duration(1)
v := math.Inf(t)
}
produces the error: cannot use t (type time.Duration) as type int64 in function argument
The issue is with Go's arithmetic operators subverting the type system more than with the type system itself.