When people search for golang int, go int, int golang, golang int types, golang int size, golang int vs int32, golang data types, golang types, golang data types size, or go int types, they are usually mapping familiar “integer” ideas onto Go’s numeric rules. Go splits integers into implementation-sized types (int and uint) and fixed-width types (int8 through int64 and uint8 through uint64), plus the aliases byte (uint8) and rune (int32). The language spec is the source of truth for names and widths.
Tested with Go 1.24 on Linux.
Signed integer types
The signed golang types are int, int8, int16, int32, and int64. The first is special: int is implementation-specific—typically the same width as a machine word (often 32 bits on 386 and 64 bits on amd64). The others are always exactly as wide as their names suggest.
| Type | Size | Signed | Typical use |
|---|---|---|---|
int |
32 or 64 bits per implementation | yes | Indexes, len, cap, general arithmetic on the current platform |
int8 |
8 bits | yes | Small packed fields, tight structs |
int16 |
16 bits | yes | Legacy formats, sensors, narrow ranges |
int32 |
32 bits | yes | Stable wire size, rune, APIs that require 32-bit ints |
int64 |
64 bits | yes | Epoch-nanosecond times, large counters, explicit 64-bit APIs |
Exact min and max values are the usual two's-complement ranges for each width; the math package exposes constants such as math.MaxInt32 and math.MaxInt64 when you need them in code.
golang int vs int32
The phrase golang int vs int32 is mostly about portability: int32 is always four bytes. int matches the natural word-sized integer for the target, so the same source line can mean a 32-bit or 64-bit variable depending on GOARCH. Use int32 when a protocol or database column is explicitly 32-bit; use int when you follow for i := 0; i < len(s); i++ style loops and standard library APIs that take int.
Seeing golang int size on your machine
You can print storage sizes with unsafe.Sizeof. Sizes are compile-time constants for a given build configuration:
package main
import (
"fmt"
"unsafe"
)
func main() {
var i int
var i32 int32
var i64 int64
fmt.Printf("int %d bytes, int32 %d bytes, int64 %d bytes\n",
unsafe.Sizeof(i), unsafe.Sizeof(i32), unsafe.Sizeof(i64))
}On a typical 64-bit Linux build, int and int64 are often eight bytes and int32 is four; on a 32-bit int build, int is usually four bytes while int64 stays eight.
Unsigned integer types
Unsigned golang types are uint, uint8, uint16, uint32, and uint64. uint is implementation-sized the same way int is; the uint8–uint64 types have fixed bit widths. Unsigned arithmetic wraps modulo 2 to the power of the type's bit width; there is no negative representable value.
| Type | Size | Notes |
|---|---|---|
uint |
32 or 64 bits | Matches unsigned word size for the implementation |
uint8 |
8 bits | Alias name byte |
uint16 |
16 bits | Larger unsigned ranges without uint32 overhead |
uint32 |
32 bits | CRCs, IPv4 addresses as numbers, masks |
uint64 |
64 bits | Large bitmasks, hardware registers, sync/atomic on 64-bit values |
Aliases: byte and rune
byteis an alias foruint8. Use it for raw binary data and UTF-8 bytes.runeis an alias forint32. Use it for Unicode code points (a singleruneis one code point, not necessarily one user-visible character in all languages).
Choosing among golang types
- Default loops and slices: prefer
intfor indexes and lengths so you matchlenand standard library signatures. - Stable layout: pick
int32,int64, or an unsigned fixed width when a file format, RPC schema, or SQL type dictates the width. - Interop and narrowing: converting between
intandint64is explicit in Go; if you narrowint64toint, read int and int64 conversions for platform caveats. - Clarity over micro-optimization: smaller ints save memory only when they matter at scale; otherwise fixed widths mainly document intent.
Summary
Go’s integer story separates implementation-sized int/uint from fixed-width int8–int64 and uint8–uint64, which answers most golang int size and golang data types size questions in terms of the spec and GOARCH. golang int vs int32 comes down to fixed four-byte int32 versus variable-width int. For everyday code, int stays the default for golang int / go int style arithmetic; reach for sized types and byte/rune aliases when the problem domain names a width or encoding.
References
- The Go Programming Language Specification: Numeric types
mathpackage constants (MaxInt32,MaxUint64, …)unsafe.Sizeof

