Chapter 15: Go Data Types

Go Data Types — which usually means the full picture of types in Go, not just the primitives.

In most tutorials (especially “A Tour of Go” style, W3Schools, GeeksforGeeks, YouTube beginner series), “Go Data Types” covers:

  1. Basic / Built-in / Predeclared types (what we did last time)
  2. Composite / Derived / Aggregate types (the ones you build yourself or from basics)

Today let’s do the complete overview like a patient human teacher — from the official spec (go.dev/ref/spec#Types, updated Jan 2026 for Go 1.26) + Tour of Go (go.dev/tour/basics/11 and moretypes section).

We’ll go group by group, with tables, zero values, declaration examples, when to choose which, common mistakes, and runnable code you can try right now.

1. Overview — All Categories of Types in Go (2026)

Go has two big families:

  • Predeclared / Basic types (built-in, no need to define)
  • Composite types (constructed from other types)
Category Examples Defined with keyword Zero value example Most common?
Basic / Numeric bool, int, float64, string, byte, rune false, 0, “”, nil Very high
Composite — Array [5]int [size]T all elements zero Medium
Composite — Slice []int []T nil Extremely high
Composite — Struct struct { Name string; Age int } struct { … } fields zero Very high
Composite — Pointer *int *T nil High
Composite — Function func(int) string func(…) … nil High
Composite — Interface interface { String() string } interface { … } nil Very high
Composite — Map map[string]int map[K]V nil Extremely high
Composite — Channel chan int chan T nil Medium–high

2. Quick Recap — Basic / Predeclared Types (Primitives)

(We covered these last time — just the table for reference)

Type family Types Zero value Typical size Recommendation / Notes
Boolean bool false 1 byte
Signed integer int, int8, int16, int32, int64 0 8/16/32/64 bit Use int most times
Unsigned integer uint, uint8, uint16, uint32, uint64, uintptr 0 same uint for sizes, byte = uint8
Floating point float32, float64 0.0 4/8 bytes Always prefer float64
Complex complex64, complex128 0+0i 8/16 bytes Rare outside math
String string “” Immutable UTF-8 bytes
Aliases byte (= uint8), rune (= int32) 0 1 / 4 bytes Use byte for raw data, rune for Unicode chars

Example recap:

Go

3. Composite Types — The Real Power (Where Go Shines)

These are the types you actually build most programs with.

a) Arrays — Fixed-size collections

  • Size part of the type → [5]int ≠ [6]int
  • Zero value: all elements zero-valued
Go

Rarely used directly — most people prefer slices.

b) Slices — Dynamic views on arrays (Most used collection!)

  • Reference type → nil zero value
  • Very flexible: append, slicing, capacity
Go

c) Structs — Custom record types (like classes without methods yet)

Go

d) Pointers — *T (address of something)

Go

e) Maps — Hash tables (key → value)

Go

f) Channels — For concurrency (Go’s superpower)

Go

4. Quick Reference Table — Zero Values & Nilability

Type category Zero value Is nil possible? Can be compared with == ?
bool, numeric, string false / 0 / 0.0 / “” No Yes
Pointer, slice, map, channel, function, interface nil Yes Yes (only nil == nil)
Array, struct zero of each field/element No Yes (deep equality)

5. Your Practice Task Right Now

Create data_types.go and mix everything:

Go

Run → see zero values + composite nesting.

Questions now?

  • Deep dive on slices (append vs copy, capacity tricks)?
  • Struct embedding vs inheritance?
  • When to use pointer receivers?
  • Or next: type conversions? interfaces? methods?

Keep running code — you’re turning into a real Go pro one concept at a time! 💪🇮🇳 Let’s keep it going! 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *