Go Data Types
Go (Golang) – Data Types
Go is a statically typed language, meaning every variable has a specific data type known at compile time. Go data types are broadly divided into basic, composite, and derived types.
1️⃣ Basic Data Types
🔹 Integer Types
| Type | Size | Description |
|---|---|---|
int |
32/64-bit | Platform dependent |
int8 |
8-bit | −128 to 127 |
int16 |
16-bit | −32,768 to 32,767 |
int32 |
32-bit | Unicode / rune |
int64 |
64-bit | Large numbers |
uint |
32/64-bit | Unsigned integer |
uint8 |
8-bit | Alias: byte |
uint16 |
16-bit | |
uint32 |
32-bit | |
uint64 |
64-bit |
🔹 Floating-Point Types
| Type | Size |
|---|---|
float32 |
32-bit |
float64 |
64-bit (default) |
🔹 Complex Types
| Type | Description |
|---|---|
complex64 |
float32 real + imag |
complex128 |
float64 real + imag |
🔹 Boolean Type
🔹 String Type
✔ UTF-8 encoded
✔ Immutable
2️⃣ Composite Data Types
🔹 Arrays (Fixed Size)
🔹 Slices (Dynamic)
🔹 Maps (Key–Value Pair)
🔹 Structs (User-defined Type)
3️⃣ Derived Data Types
🔹 Pointers
🔹 Functions as Types
🔹 Interfaces
4️⃣ Special Types
| Type | Description |
|---|---|
byte |
Alias for uint8 |
rune |
Alias for int32 (Unicode) |
uintptr |
Pointer arithmetic |
nil |
Zero value for reference types |
5️⃣ Type Conversion (Not Automatic)
❌ Invalid:
✅ Valid:
6️⃣ Checking Data Type
Summary
-
Go has strong & static typing
-
No implicit type conversion
-
Supports basic, composite & derived types
-
UTF-8 string support built-in
