Go from scratch: basic types and control flow, functions, interfaces, error handling, packages and modules, then goroutines, channels and concurrency.
Articles
47
Reading time
~6 h
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 statically typed, compiled and garbage-collected, and still 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 part of the language itself
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 one core 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
Articles
01/ 47
Introduction to Go
Where Go came from, why Google built it, who designed it, and the design principles behind its fast compiler, small language and built-in concurrency.
6 minutes read
02/ 47
Basic types
Go's built-in types, from integers and floats to booleans and strings, how Go's type system treats them, and what each one costs in memory.
6 minutes read
03/ 47
Variables and constants
How Go names values with var, short declarations and constants, how type inference and zero values work, and what separates variables from constants.
7 minutes read
04/ 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
05/ 47
Operators
Go's arithmetic, comparison, logical, bitwise, shift and pointer operators, how they combine into expressions, and the precedence rules between them.
7 minutes read
06/ 47
Strings
How Go strings work: immutable UTF-8 byte sequences that handle Unicode, plus indexing, slicing, conversions and how to iterate over them correctly.
8 minutes read
07/ 47
Conditionals
Go's if, else, else if and if-with-init statements, why conditions must be a strict bool, and how scoped variables keep error handling short.
4 minutes read
08/ 47
Arrays and slices
Go's fixed-size arrays and dynamic slices: how slices wrap arrays under the hood, how capacity and growth work, and how to avoid shared-memory pitfalls.
9 minutes read
09/ 47
Maps
How Go's built-in map type works: nil vs empty maps, reading with the comma-ok idiom, writing, unique keys, and which comparable types can be keys.
4 minutes read
10/ 47
Structs
How Go structs model real-world data by grouping fields into custom types, plus zero values, positional vs named initialization, and dot notation.
3 minutes read
11/ 47
Code blocks and scope
How Go nests code into blocks, which variables each block can see, and how shadowing with := hides an outer variable without a compiler error.
5 minutes read
12/ 47
The for loop
Go has a single loop keyword, for, and it covers what while and do-while do elsewhere. Learn its three forms and how range works over slices, maps and channels.
6 minutes read
13/ 47
Break, continue, labels, and goto
Control loop flow in Go with break and continue, use labels to leave or skip an outer loop from a nested one, and see where goto fits and why to avoid it.
7 minutes read
14/ 47
The switch statement
How Go's switch works: cases that don't fall through, an init clause, several values in one case, the expressionless form and the fallthrough keyword.
6 minutes read
15/ 47
Functions
How to declare Go functions, pass parameters, return one or several values, use named returns and variadic parameters, and treat functions as values.
9 minutes read
16/ 47
Closures and anonymous functions
A closure is a function that captures variables from its surrounding scope. How closures work in Go, why they keep state between calls, and where to use them.
6 minutes read
17/ 47
Defer
Go's defer runs a call just before the surrounding function returns. How it works, when its arguments are evaluated, and how to use it for cleanup.
5 minutes read
18/ 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
19/ 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
20/ 47
Types and methods
Defining and deriving custom types in Go, attaching methods to them, how receivers and method sets work, and using iota for typed constant sequences.
11 minutes read
21/ 47
Embedding
Learn how Go uses embedding to compose structs, promote fields and methods, and satisfy interfaces, all without inheritance.
6 minutes read
22/ 47
Interfaces
Learn how Go interfaces describe behavior implicitly, how one type satisfies several interfaces, and how to use the empty interface and type assertions.
10 minutes read
23/ 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
24/ 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
25/ 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
26/ 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
27/ 47
Project structure
How to lay out a Go project, from a single-file library to an application with several packages, internal packages, more than one binary and a workspace.
8 minutes read
28/ 47
io.Reader and io.Writer
How Go's io.Reader and io.Writer give files, HTTP bodies, buffers and network connections one I/O API, and how to implement them yourself.
7 minutes read
29/ 47
os and bufio
Reading and writing files, processing text line by line, environment variables and command-line arguments with Go's os and bufio packages.
8 minutes read
30/ 47
JSON in Go
Marshalling and unmarshalling JSON in Go, choosing field names with struct tags, and streaming JSON through an io.Reader or io.Writer with Encoder and Decoder.
8 minutes read
31/ 47
Time in Go
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
32/ 47
HTTP in Go
Building HTTP clients and servers in Go with the net/http package, from making requests with a timeout to routing with ServeMux and path wildcards.
9 minutes read
33/ 47
Context package
How Go's context package carries cancellation, deadlines and request-scoped values across API boundaries and between goroutines, with real examples.
8 minutes read
34/ 47
Testing
How Go's built-in testing package and go test command work, from basic assertions to table-driven tests, subtests, cleanup and package-level setup.
9 minutes read
35/ 47
Generics
How Go generics let one function or type work across many types with type parameters and constraints, without duplicated code or interface{} casts.
10 minutes read
36/ 47
The fmt package in depth
Go's fmt package in depth: format verbs, width and alignment, the Stringer and GoStringer interfaces, and the full family of print and scan functions.
11 minutes read
37/ 47
Concurrency challenges
What concurrency is, how it differs from parallelism on multi-core machines, and the problems it brings: race conditions, atomicity and critical sections.
8 minutes read
38/ 47
Deadlocks, livelocks, and starvation
How to identify and prevent deadlocks, livelocks and starvation, the three classic concurrency hazards in Go, with code examples and practical fixes.
11 minutes read
39/ 47
Go's concurrency model
Go's concurrency philosophy and its roots in CSP, and how goroutines, channels, select and the sync package fit together into one model for concurrent programs.
9 minutes read
40/ 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
41/ 47
sync — WaitGroup and mutexes
How to wait for a group of goroutines with sync.WaitGroup, why data races happen, and how Mutex and RWMutex protect shared state in critical sections.
7 minutes read
42/ 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
43/ 47
Channels
Learn how Go channels let goroutines communicate safely, covering creation, direction, blocking semantics, buffering and ownership patterns.
10 minutes read
44/ 47
The select statement
How Go's select statement waits on several channel operations at once, how it handles timeouts and default cases, and how the for-select loop works.
7 minutes read
45/ 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
46/ 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
47/ 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.