Skip to main content
Go Programming Language

Go Programming Language

Learn Go from scratch. This series covers the full language: from basic types and control flow to functions, interfaces, error handling, goroutines, and module management.

A language built for clarity

Go was designed at Google to solve real engineering problems: slow builds, hard-to-read code, and poor concurrency support. The result is a language that is statically typed, compiled, and garbage-collected — yet feels as productive as a dynamic language.

Why Go

  • Simple syntax: A small set of keywords and consistent rules mean less time reading docs
  • Fast compilation: Builds in seconds, even for large projects
  • Built-in concurrency: Goroutines and channels are first-class citizens
  • Strong standard library: Most things you need are already included
  • Readable by default: Code is easy to follow even for newcomers to the language

What you'll learn

Each article in this category covers a foundational Go concept:

  • The core types Go provides and how memory works behind them
  • Variables, constants, and how Go handles declarations
  • Identifiers, keywords, and naming rules
  • Operators: arithmetic, comparison, logic, and bitwise
  • Strings: encoding, manipulation, and Unicode
  • Control flow: conditionals, loops, switch, break, continue, labels, and goto
  • Composite types: arrays, slices, maps, and structs
  • Functions, multiple return values, variadic parameters, and closures
  • Defer, and how it interacts with panic and recover
  • Pointers and Go's call-by-value model
  • Methods, custom types, and struct embedding
  • Interfaces: structural typing, the empty interface, type assertions, and type switches
  • Errors: custom error types, wrapping, and errors.Is / errors.As
  • Dependency management with Go modules
  • Package design and code organization
  • Project structure patterns: from a single file to multi-binary services and workspace mode
47 articles
Introduction to Go

Introduction to Go

Discover the origins of Go — why Google built it, who designed it, and the core principles that make it fast, simple, and built for the modern era of software.

6 minutes read
Read article
Basic types

Basic types

Explore Go's built-in types — integers, floats, booleans, strings and more. Understand how Go's type system works and what each type costs in memory.

6 minutes read
Read article
Variables and constants

Variables and constants

Learn how Go names values — the var keyword, short declarations, and constants. Understand type inference, zero values, and the difference between mutable and immutable bindings.

7 minutes read
Read article
Identifiers and keywords

Identifiers and keywords

Understand Go's naming rules, the 25 reserved keywords, and the predeclared identifiers that come built into every Go program.

7 minutes read
Read article
Operators

Operators

Master Go's operators — arithmetic, comparison, logical, bitwise, and assignment. Learn operator precedence and how Go handles expressions.

7 minutes read
Read article
Strings

Strings

Deep dive into Go strings — stored as UTF-8 byte sequences, immutable, and fully Unicode-aware. Learn indexing, slicing, conversions, and how to iterate correctly.

8 minutes read
Read article
Conditionals

Conditionals

Master Go's conditional statements — if, else, else if, and if init statements. Learn how Go enforces strict boolean conditions and how scoped variables make error handling cleaner.

4 minutes read
Read article
Arrays and slices

Arrays and slices

Master Go's two core sequence types — fixed-size arrays and dynamic slices. Learn how slices wrap arrays under the hood, how capacity and growth work, and how to avoid the shared-memory pitfalls.

9 minutes read
Read article
Maps

Maps

Learn how Go's built-in map type works — nil vs empty maps, reading with the comma-ok idiom, writing, key uniqueness, and comparable type constraints.

4 minutes read
Read article
Structs

Structs

Learn how Go structs let you model real-world data by grouping fields into custom types. Covers zero values, positional vs named initialization, and dot notation.

4 minutes read
Read article
Code blocks and scope

Code blocks and scope

Understand how Go organizes code into nested blocks and how variable scope flows through them. Learn the block hierarchy, scope rules, and how shadowing works — and why it should be avoided.

5 minutes read
Read article
The for loop

The for loop

Go has only one loop construct — for — but it covers every use case. Learn the three forms of for, how range works across arrays, slices, strings, maps and channels, and when to reach for each form.

6 minutes read
Read article
Break, continue, labels, and goto

Break, continue, labels, and goto

Learn how to control loop flow in Go with break and continue, how labels extend them to nested loops, and where goto fits — and when to avoid it.

7 minutes read
Read article
The switch statement

The switch statement

Go's switch is cleaner and more powerful than most languages. Learn how it handles multiple code paths, initialization, multi-condition cases, and fallthrough.

6 minutes read
Read article
Functions

Functions

Functions are the building blocks of every Go program. Learn how to declare them, pass parameters, return values, and use Go's distinctive multiple return values.

10 minutes read
Read article
Closures and anonymous functions

Closures and anonymous functions

Closures are functions that capture variables from their surrounding scope. Learn how they work in Go, why they retain state, and where they are most useful.

6 minutes read
Read article
Defer

Defer

The defer statement schedules a function call to run just before the surrounding function returns. Learn how it works, when arguments are evaluated, and how to use it for cleanup.

6 minutes read
Read article
Pointers

Pointers

Learn how Go pointers work, when to use them for mutability and performance, and how Go's garbage collector manages heap memory.

8 minutes read
Read article
Call by value and call by reference

Call by value and call by reference

Understand how Go passes arguments to functions, why it is strictly call by value, and how maps and slices appear to behave like references.

8 minutes read
Read article
Types and methods

Types and methods

Learn how to define and derive custom types in Go, attach behavior with methods, understand receivers and method sets, and use iota for typed constant sequences.

12 minutes read
Read article
Embedding

Embedding

Learn how Go uses embedding to compose structs, promote fields and methods, and satisfy interfaces — without inheritance.

6 minutes read
Read article
Interfaces

Interfaces

Learn how Go interfaces define behavior implicitly, how types satisfy multiple interfaces, and how the empty interface and type assertions unlock flexible, maintainable code.

10 minutes read
Read article
Errors

Errors

Learn how Go handles errors explicitly through return values, how to create and wrap errors, and how to compare them using errors.Is and errors.As.

9 minutes read
Read article
Panic and recover

Panic and recover

Learn when Go raises a panic, how it unwinds the call stack, and how recover lets packages catch panics and return meaningful errors instead of crashing.

6 minutes read
Read article
Packages

Packages

Learn how Go packages organize code, how exported identifiers work, how the init function runs, and the idioms for naming, aliases, and side-effect imports.

7 minutes read
Read article
Dependency management

Dependency management

Learn how Go modules manage dependencies using go.mod and go.sum, how to add and remove packages, and how to keep your module files clean with go mod tidy.

4 minutes read
Read article
Project structure

Project structure

Learn how to structure Go projects from a single-file library to multi-package applications with internal packages, multiple executables, and workspace mode.

9 minutes read
Read article
io.Reader and io.Writer

io.Reader and io.Writer

Learn how Go's io.Reader and io.Writer interfaces unify I/O across files, HTTP, buffers, and more — and how to implement them yourself.

8 minutes read
Read article
os and bufio

os and bufio

Learn how to read and write files, process text line by line, manage environment variables, and access command-line arguments using Go's os and bufio packages.

8 minutes read
Read article
JSON in Go

JSON in Go

Learn how to marshal and unmarshal JSON in Go, control field names with struct tags, and stream JSON efficiently using Encoder and Decoder.

8 minutes read
Read article
Time in Go

Time in Go

Learn how Go represents time with wall clock and monotonic readings, and how to work with the time.Time and time.Duration types from the standard library.

7 minutes read
Read article
HTTP in Go

HTTP in Go

Learn how to build HTTP clients and servers in Go using the net/http package, from making requests to routing with ServeMux and path wildcards.

9 minutes read
Read article
Context package

Context package

Learn how Go's context package enables cancellation, deadlines, and request-scoped values across API boundaries and concurrent operations.

8 minutes read
Read article
Testing

Testing

Learn how Go's built-in testing package and go test command cover everything you need, from basic assertions to table-driven tests and package-level setup.

9 minutes read
Read article
Generics

Generics

Learn how Go generics enable type-safe code reuse through type parameters and constraints, eliminating duplicate functions and unsafe interface{} casts.

10 minutes read
Read article
The fmt package in depth

The fmt package in depth

Master Go's fmt package — format verbs, width and alignment, the Stringer and GoStringer interfaces, and the full family of print and scan functions.

11 minutes read
Read article
Concurrency challenges

Concurrency challenges

Understand what concurrency is, why it matters for multi-core systems, and the challenges it introduces: race conditions, atomicity, and critical sections.

8 minutes read
Read article
Deadlocks, livelocks, and starvation

Deadlocks, livelocks, and starvation

Learn to identify and prevent the three classic concurrency hazards in Go — deadlocks, livelocks, and starvation — with code examples and practical fixes.

10 minutes read
Read article
Go's concurrency model

Go's concurrency model

Explore Go's concurrency philosophy, its roots in CSP, and how goroutines, channels, and the select statement form a coherent model for concurrent programs.

10 minutes read
Read article
Goroutines and the Go scheduler

Goroutines and the Go scheduler

Learn what goroutines are, how they differ from OS threads and green threads, and how Go's GMP scheduler multiplexes millions of goroutines across CPU cores.

11 minutes read
Read article
sync — WaitGroup and mutexes

sync — WaitGroup and mutexes

Learn how to coordinate goroutine lifetimes with WaitGroup and protect shared state with Mutex and RWMutex.

7 minutes read
Read article
sync — Cond, Once, and Pool

sync — Cond, Once, and Pool

Learn advanced sync primitives: condition variables for event signaling, Once for safe one-time init, and Pool for reducing GC pressure.

8 minutes read
Read article
Channels

Channels

Learn how Go channels enable safe communication between goroutines — creation, direction, blocking semantics, buffering, and ownership patterns.

10 minutes read
Read article
The select statement

The select statement

Learn how Go's select statement coordinates multiple channel operations simultaneously, handles timeouts, and powers the for-select pattern for reactive goroutines.

7 minutes read
Read article
Preventing goroutine leaks

Preventing goroutine leaks

Learn how goroutines leak, why the GC cannot help, and how the done channel and context patterns give every goroutine a guaranteed exit path.

8 minutes read
Read article
Handling errors in goroutines

Handling errors in goroutines

Learn two patterns for propagating errors from concurrent goroutines — the result struct and the separate error channel — and when to choose each.

7 minutes read
Read article
Pipelines, fan-out, and fan-in

Pipelines, fan-out, and fan-in

Learn how to structure concurrent Go programs as pipelines of stages connected by channels, and how fan-out and fan-in parallelize the expensive ones.

7 minutes read
Read article