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.
In this tutorial, we will find the max int value on the platform on which you use the Go language.
Golang max int
The maximum value for an int type in the Golang is defined by the size of a type specified by the specification.
The maximum value of int depends on the size of int on the platform where the Golang code is executing.
To get the maximum value of the int64 type, use math.MaxInt64 constant.
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("int64 max: %d\n", math.MaxInt64)
}
Output
int64 max: 9223372036854775807
On 64-bit platforms, the integer is normally 64 bits, so the maximum value of int is 9223372036854775807.
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("int32 max: %d\n", math.MaxInt32)
}
Output
int32 max: 2147483647
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 Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. In addition, Krunal has excellent knowledge of Distributed and cloud computing and is an expert in Go Language.