math.MaxUint64 is a constant, not int64. Try instead:
fmt.Printf("%d", uint64(num))
The problem here is that the constant is untyped. The constant will take on a type depending on the context in which it is used. In this case, it is used as the {} interface, so the compiler does not know which specific type you want to use. For integer constants, it defaults to int . Since your constant overflows int, this is a compile-time error. By uint64(num) , you tell the compiler that you want the value to be treated as uint64 .
Note that this particular constant will only match uint64, and sometimes uint. It is even larger than standard int64.
Stephen weinberg
source share