Learning series

Go basics: 50 practical lessons

Learn Go step by step: syntax, collections, functions, errors, testing, HTTP and concurrency, with examples and official documentation.

50 articles · English and Spanish · Beginner level

Start with lesson 1

Learning path

  1. Learn Go basics: a path through 50 practical lessonsLearn Go through 50 connected lessons with runnable examples, exercises, common mistakes, testing, concurrency and a final HTTP project.2 min read

First steps and syntax

  1. Install Go and understand the basic development workflowSet up Go, verify the toolchain and learn when to use go run, go build and go test in a small local module.2 min read
  2. Hello World in Go: packages, imports and mainWrite your first Go program and understand package main, imports, function declarations and formatted output.2 min read
  3. Go modules and packages: how imports find your codeOrganize a small Go module with two packages and understand module paths, exported names and go mod tidy.2 min read
  4. Format and check Go code with gofmt and go vetUse the built-in Go formatter, vet checks and tests to keep a small project consistent and catch common mistakes.2 min read
  5. Variables and zero values in Go: var versus :=Declare Go variables with var and short declarations, understand zero values and avoid accidental shadowing.2 min read
  6. Constants and iota in Go: represent fixed valuesLearn typed and untyped Go constants, use iota for simple enumerations and avoid unstable external numeric values.2 min read
  7. Go basic types: integers, floats, booleans and stringsChoose Go basic types, understand int and fixed-width integers, and recognize integer division and floating-point limits.2 min read
  8. Type conversion and string parsing in GoConvert numeric values explicitly and parse strings with strconv.Atoi while checking invalid input and conversion limits.2 min read
  9. Go conditionals: if, switch and early returnsUse boolean conditions, scoped if initializers and switch cases to make Go decisions readable and explicit.2 min read
  10. Go for loops: counters, conditions and terminationWrite Go loops with counters or conditions and understand break, continue and reliable termination.2 min read

Data and collections

  1. Go collections: start with arrays and value semanticsUnderstand fixed-size Go arrays and use this guide to navigate slices, maps, strings, structs and pointers.2 min read
  2. Go slices: length, capacity and shared storageUnderstand how Go slices refer to backing arrays, why subslices share elements and when to make an independent copy.2 min read
  3. append and copy in Go: grow slices without surprisesUse append correctly, understand backing-array reuse and copy a slice before making independent modifications.2 min read
  4. Go maps: lookup, presence checks and safe initializationCreate Go maps, distinguish missing keys from zero values and understand nil maps and unspecified iteration order.2 min read
  5. Go range: iterate collections without confusing copiesIterate Go slices, maps and strings with range and learn why changing the iteration value may leave the source unchanged.2 min read
  6. Go strings: bytes, immutability and common operationsWork with Go strings using strings.TrimSpace, Split and Join, while distinguishing byte length from Unicode text length.2 min read
  7. Unicode in Go: rune counts and byte offsetsCompare byte lengths with rune counts, iterate UTF-8 text and understand why a rune is not always a visible character.2 min read
  8. Sort Go data and produce deterministic map outputSort strings and integers with the standard library and sort map keys before generating predictable output.2 min read
  9. Go structs: group related fields into a valueDefine Go structs, use named fields in literals and understand copying, exported fields and nested mutable data.2 min read
  10. Go pointers: addresses, dereferencing and nilUse Go pointers to update existing values, understand parameter copying and check nil before dereferencing.2 min read

Functions and contracts

  1. Go functions: parameters, results and small contractsDefine Go functions with explicit inputs and results, then follow the guide to errors, methods, interfaces and generics.2 min read
  2. Multiple return values in Go: results and presenceReturn multiple values from Go functions and use a boolean result to distinguish an empty collection from a valid zero.2 min read
  3. Variadic functions in Go: accept zero or more argumentsUse variadic Go parameters, expand slices with ... and define the behavior of calls with no arguments.2 min read
  4. Go scope and closures: capture variables deliberatelyUnderstand lexical scope and build a small Go closure while recognizing shared captured state and shadowing.2 min read
  5. Go defer: release resources at the right boundaryUnderstand when deferred Go calls run, argument evaluation and why deferring cleanup inside a long loop can retain resources.2 min read
  6. Error handling in Go: return, check and add contextReturn ordinary Go errors for expected failures and keep invalid results from entering the successful execution path.2 min read
  7. Wrap Go errors with %w and inspect them with errors.IsAdd context to Go errors without losing their identity, and distinguish errors.Is from fragile message comparisons.2 min read
  8. Go methods: choose value or pointer receiversAttach methods to named Go types and choose receiver semantics based on mutation, copying and method sets.2 min read
  9. Go interfaces: define the behavior a caller needsBuild a small implicitly satisfied Go interface, use pointer method sets correctly and understand the typed-nil trap.2 min read
  10. Go generics for beginners: type parameters and constraintsWrite a small generic Go function with a comparable constraint and learn when concrete types or interfaces remain clearer.2 min read

Standard library and testing

  1. Go standard library: connect readers, writers and toolsExplore Go standard-library building blocks through io.Reader and io.Writer, then continue with files, JSON, HTTP and tests.2 min read
  2. Read and write small files in Go with explicit cleanupUse os.ReadFile and os.WriteFile for small local files, propagate errors and isolate practice data in a temporary directory.2 min read
  3. Read text line by line in Go with bufio.ScannerProcess Go text input line by line, check Scanner.Err and set an explicit token limit for controlled input sizes.2 min read
  4. JSON in Go: exported fields, tags and validationEncode and decode Go structs with encoding/json and separate valid JSON syntax from application-level validation.2 min read
  5. Go time basics: durations, layouts and time zonesParse and format Go timestamps, use time.Duration with explicit units and distinguish time zones from fixed offsets.2 min read
  6. Environment variables in Go: defaults and validationRead Go environment configuration with os.LookupEnv and validate numeric values before using them.2 min read
  7. Command-line flags in Go: parse options with flagBuild a small Go command with typed flags, usage help and semantic validation after parsing.2 min read
  8. Build a first HTTP handler in Go with net/httpServe a local HTTP endpoint in Go, set response metadata and configure basic server timeouts.2 min read
  9. Go HTTP clients: timeouts, status checks and body closureCall a local HTTP endpoint with a reusable Go client, enforce a timeout and bound the response body.2 min read
  10. Go unit tests: table-driven cases and useful failuresWrite Go tests with independent expected results, table-driven cases and descriptive subtest failures.2 min read

Concurrency and final project

  1. Go concurrency: start a goroutine and wait for its resultUnderstand goroutine lifetimes and use this guide to learn synchronization, channels, cancellation and race detection.2 min read
  2. sync.WaitGroup in Go: wait for a known set of tasksCoordinate Go task completion with WaitGroup and understand why waiting does not protect shared mutable state.2 min read
  3. Go channels: buffered and unbuffered communicationSend typed values between Go goroutines and understand when channel operations block and what buffering changes.2 min read
  4. Close Go channels: signal completion without panicsUse channel closure to finish a range loop, drain buffered values and avoid sends or repeated closes after completion.2 min read
  5. Go select: coordinate ready operations and cancellationChoose between Go channel operations with select and avoid busy loops and assumptions about ready-case priority.2 min read
  6. Go context: propagate cancellation and deadlinesPass cancellation through Go function boundaries with context.Context and release derived-context resources with cancel.2 min read
  7. sync.Mutex in Go: protect a shared invariantProtect concurrent Go counter updates with a mutex and understand lock scope, consistent access and copying restrictions.2 min read
  8. Go race detector: find executed data races with -raceRun Go race checks, interpret conflicting access reports and understand why a clean run is limited to executed paths.2 min read
  9. Go basics final project: a tested JSON HTTP endpointCombine Go functions, structs, JSON, validation and httptest in a small local HTTP project with a reproducible test.2 min read
© 2026 Juan Miguel Arias Mejias