Having said that it doesn't change the fact that looking into the 'flaky' test was the right thing to do. Even if the type system were different I'm sure I would have shot myself in the foot in some other way.
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.