I've been working on metaprogramming involving packages and I've been running into the error constant 9223372036854775807 overflows int
whenever math.MaxInt64
and math.MaxUint64
show up.
I've isolated it into two cases:
Valid
var a int64 = math.MaxInt64
b := interface{}(int64(math.MaxInt64))
Not Valid
a := math.MaxInt64
b := interface{}(math.MaxInt64)
https://play.golang.org/p/U1QDmFbV29
It seems like that Go doesn't do correct type inference.
Is this a bug or expected behavior? And if expect, does anyone know why?