Skip to main content

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
Go Programming Language01 / 47

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
Go Programming Language02 / 47

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
Go Programming Language03 / 47

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
Go Programming Language04 / 47

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
Go Programming Language05 / 47

Operators

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

7 minutes read
Go Programming Language06 / 47

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
Go Programming Language07 / 47

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
Go Programming Language08 / 47

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
Go Programming Language09 / 47

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
Go Programming Language10 / 47

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
Go Programming Language11 / 47

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
Go Programming Language12 / 47

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
Go Programming Language13 / 47

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
Go Programming Language14 / 47

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
Go Programming Language15 / 47

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
Go Programming Language16 / 47

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
Go Programming Language17 / 47

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
Go Programming Language18 / 47

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
Go Programming Language19 / 47

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
Go Programming Language20 / 47

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
Go Programming Language21 / 47

Embedding

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

6 minutes read
Go Programming Language22 / 47

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
Go Programming Language23 / 47

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
Go Programming Language24 / 47

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
Go Programming Language25 / 47

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
Go Programming Language26 / 47

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
Go Programming Language27 / 47

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
Go Programming Language28 / 47

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
Go Programming Language29 / 47

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
Go Programming Language30 / 47

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
Go Programming Language31 / 47

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
Go Programming Language32 / 47

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
Go Programming Language33 / 47

Context package

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

8 minutes read
Go Programming Language34 / 47

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
Go Programming Language35 / 47

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
Go Programming Language36 / 47

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
Go Programming Language37 / 47

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
Go Programming Language38 / 47

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
Go Programming Language39 / 47

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
Go Programming Language40 / 47

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
Go Programming Language41 / 47

sync — WaitGroup and mutexes

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

7 minutes read
Go Programming Language42 / 47

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
Go Programming Language43 / 47

Channels

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

10 minutes read
Go Programming Language44 / 47

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
Go Programming Language45 / 47

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
Go Programming Language46 / 47

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
Go Programming Language47 / 47

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