The maximum value for an int type in the Golang on 64-bit platforms is “9223372036854775807”. The max value is defined by the size of a type specified by the specification. Therefore, the maximum int value depends on the int size on the platform where the Golang code is executing.
To get the maximum value of the int64 type in Golang, you can use the “math.MaxInt64” constant.
Two predeclared integer types with implementation-specific sizes exist in Golang:
- Unsigned integers have either 32 or 64 bits.
- A signed integer has the same size as an unsigned integer.
Example 1
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("int64 max: %d\n", math.MaxInt64)
}
Output
int64 max: 9223372036854775807
Example 2
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("int32 max: %d\n", math.MaxInt32)
}
Output
int32 max: 2147483647
Example 3
If you want maximum int value based on the platform you are executing, go code, and try the below code.
package main
import (
"fmt"
)
func main() {
maxInt := int(^uint(0) >> 1)
fmt.Println(maxInt)
}
Output
9223372036854775807
You can see that I am using Macbook M1 64-bit OS. That’s why it returns the max int for 64-bit platforms.
That’s pretty much it.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.