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.

Start learning →

Go Basics

  1. Go Introduction — What Go is, why it's popular for back-end services and what a Go program looks like.
  2. Go Get Started — Install Go, create a module and run your first program.
  3. Go Syntax — Packages, imports, functions, statements and Go's formatting rules.
  4. Go Variables — Declare variables with var and :=, zero values and multiple assignment.
  5. Go Data Types — Integers, floats, strings, booleans, bytes, runes and type conversion.
  6. Go Constants — Declare constants with const and generate enum-like values with iota.
  7. Go Operators — Arithmetic, comparison, logical and bitwise operators.
  8. Go Strings — String basics, the strings package, runes, formatting with fmt and strings.Builder.
  9. 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

  1. Go If Else — Conditions, if with a short statement, and error checks.
  2. Go Switch — Switch on values, switch with no condition, and fallthrough.
  3. Go For Loops — Go's only loop: classic for, while-style, infinite loops and range.

Data Structures

  1. Go Arrays and Slices — Fixed-size arrays, dynamic slices, append, slicing and capacity.
  2. Go Maps — Key-value maps: create, read, check existence, delete and iterate.
  3. Go Structs — Group fields into structs, struct literals, embedding and tags.
  4. Go Pointers — Addresses with & and *, passing by pointer, and nil.

Functions and Methods

  1. Go Functions — Parameters, multiple return values, named results and variadic functions.
  2. Go Closures and defer — Anonymous functions, closures, function values and deferred calls.
  3. Go Methods — Attach methods to types with value and pointer receivers.
  4. Go Interfaces — Implicit interfaces, polymorphism, the empty interface and type switches.
  5. Go Generics — Type parameters for functions and types, and constraints.

Errors

  1. Go Error Handling — error values, wrapping with %w, errors.Is and errors.As, panic and recover.

Concurrency

  1. Go Goroutines and WaitGroup — Run functions concurrently with go, and wait for them with sync.WaitGroup.
  2. Go Channels and select — Send values between goroutines, buffered channels, range over channels and select.
  3. Go Context — Cancel work and set deadlines with context.Context.

Standard Library

  1. Go JSON — Encode and decode JSON with encoding/json and struct tags.
  2. Go File Handling — Read and write files with the os and bufio packages.
  3. Go HTTP Server — Build a small JSON API with net/http — no framework needed.
  4. Go Testing — Write table-driven tests with the testing package and go test.

Next Steps

  1. Go Next Steps — Projects, the Go ecosystem and interview practice.