Free tutorial · 30 lessons
Go Tutorial
Learn Go (Golang) step by step: variables, types, slices, maps, structs, pointers, functions, methods, interfaces, generics, error handling, goroutines, channels, context, JSON, files and HTTP — every example shown with its output.
Go Basics
- Go Introduction — What Go is, why it's popular for back-end services and what a Go program looks like.
- Go Get Started — Install Go, create a module and run your first program.
- Go Syntax — Packages, imports, functions, statements and Go's formatting rules.
- Go Variables — Declare variables with var and :=, zero values and multiple assignment.
- Go Data Types — Integers, floats, strings, booleans, bytes, runes and type conversion.
- Go Constants — Declare constants with const and generate enum-like values with iota.
- Go Operators — Arithmetic, comparison, logical and bitwise operators.
- Go Strings — String basics, the strings package, runes, formatting with fmt and strings.Builder.
- Go History & Versions — Why three Google engineers designed Go, the Go 1 compatibility promise, every important release from Go 1.0 to 1.27 on one timeline (including generics), and which version to use today.
Control Flow
- Go If Else — Conditions, if with a short statement, and error checks.
- Go Switch — Switch on values, switch with no condition, and fallthrough.
- Go For Loops — Go's only loop: classic for, while-style, infinite loops and range.
Data Structures
- Go Arrays and Slices — Fixed-size arrays, dynamic slices, append, slicing and capacity.
- Go Maps — Key-value maps: create, read, check existence, delete and iterate.
- Go Structs — Group fields into structs, struct literals, embedding and tags.
- Go Pointers — Addresses with & and *, passing by pointer, and nil.
Functions and Methods
- Go Functions — Parameters, multiple return values, named results and variadic functions.
- Go Closures and defer — Anonymous functions, closures, function values and deferred calls.
- Go Methods — Attach methods to types with value and pointer receivers.
- Go Interfaces — Implicit interfaces, polymorphism, the empty interface and type switches.
- Go Generics — Type parameters for functions and types, and constraints.
Errors
- Go Error Handling — error values, wrapping with %w, errors.Is and errors.As, panic and recover.
Concurrency
- Go Goroutines and WaitGroup — Run functions concurrently with go, and wait for them with sync.WaitGroup.
- Go Channels and select — Send values between goroutines, buffered channels, range over channels and select.
- Go Context — Cancel work and set deadlines with context.Context.
Standard Library
- Go JSON — Encode and decode JSON with encoding/json and struct tags.
- Go File Handling — Read and write files with the os and bufio packages.
- Go HTTP Server — Build a small JSON API with net/http — no framework needed.
- Go Testing — Write table-driven tests with the testing package and go test.
Next Steps
- Go Next Steps — Projects, the Go ecosystem and interview practice.