int64(math.MaxUint64) overflows the range of int64:
package main
import (
"fmt"
"math"
)
func main() {
var x uint64 = 1<<64 - 1
fmt.Printf("%v\n", math.MaxUint64 == x) // true
var y int64 = 1<<63 - 1
fmt.Printf("%v\n", math.MaxInt64 == y) // true
var z int64 = int64(x) // -1
fmt.Printf("%v\n", z)
}
Playground: https://play.golang.org/p/J6buiaaZcFt
see https://golang.org/pkg/math/#pkg-constants and https://play.golang.org/p/iul2dgRbK2E