Skip to main content
eLearner.app

Interactive course

Go Course

Learn Go from scratch, in English. Exercises with static validation and direct links to the official Go Playground to run your code on the real compiler.

Static verification via keywords + execution on the official Go Playground (one click for copy code + open).

01 · Language basics

5 lessons

The foundations: packages, variables, types, constants, operators, and input/output with the fmt package.

  1. 1.1Variables and typesvar, the short declaration `:=`, basic types (int, float64, string, bool), and the concept of static typing.~10 min
  2. 1.2Zero value and type conversionsEvery variable has a default value; conversions are explicit (`int(x)`, `string(b)`).~10 min
  3. 1.3Constants and iota`const`, untyped constants, and the `iota` pattern for generating readable enumerations.~10 min
  4. 1.4OperatorsArithmetic, comparison, logical, and bitwise; precedence and differences from other languages.~8 min
  5. 1.5Input/output with fmt`fmt.Println`, `fmt.Printf`, format verbs (`%d`, `%s`, `%v`, `%T`) and when to prefer one over the other.~10 min

02 · Control flow

5 lessons

Decisions and repetitions: if with init statements, the single `for`, idiomatic switch, and explicit error handling.

  1. 2.1if, else, and init statementsThe `if v := f(); v > 0 { ... }` form and why Go has no ternary operator.~10 min
  2. 2.2for: the only loopThe three forms of `for`: three-clause, single-condition (= while), and infinite; using `break` and `continue`.~10 min
  3. 2.3for...rangeIterate over slices, maps, and strings; the returned value is a copy, when to ignore index or value with `_`.~10 min
  4. 2.4Idiomatic switchNo implicit fallthrough, complex expressions in cases, switch without a condition as a chain of if.~10 min
  5. 2.5Errors: the `if err != nil` patternErrors are values; the fundamental pattern `if err != nil { return err }` and why Go has no exceptions.~12 min

03 · Functions

5 lessons

Functions as first-class citizens: signatures, multiple returns, variadic parameters, closures, and `defer`.

  1. 3.1Signature and parameters`func name(p type) type` syntax, pass-by-value by default, parameters of the same type grouped together.~10 min
  2. 3.2Multiple returns and named returnsReturning multiple values (`value, err`), the named returns pattern, and when NOT to use it.~12 min
  3. 3.3Variadic functions`func sum(nums ...int) int`, spreading a slice with `slice...`, examples from the stdlib.~10 min
  4. 3.4Closures and functions as valuesAnonymous functions that capture variables from the surrounding context; adapter and factory patterns.~12 min
  5. 3.5`defer`: guaranteed cleanupPostpone execution until return; the `defer f.Close()` pattern, LIFO order, gotchas inside loops.~12 min

04 · Collections

5 lessons

Arrays, slices (the most important structure), maps, runes inside strings, and sorting.

  1. 4.1Fixed-length arrays`[N]T` syntax, why real arrays are rarely used in Go, conversion from array to slice.~8 min
  2. 4.2Slices: the idiomatic structure`make`, `append`, len/cap, slicing `s[a:b]`, sharing the underlying array, and when to copy.~15 min
  3. 4.3Maps: keys and valuesDeclaration, comma-ok access (`v, ok := m[k]`), `delete`, non-deterministic iteration.~12 min
  4. 4.4Strings, bytes, and runesStrings are UTF-8 bytes; `range` yields runes; `len()` counts bytes, not characters.~12 min
  5. 4.5Sorting with the sort package`sort.Ints`, `sort.Strings`, `sort.Slice` with a comparison function, stability.~10 min

05 · Structs and methods

5 lessons

Composite data types: structs, methods on value or pointer receivers, composition (no inheritance), and tags.

  1. 5.1Defining and using a struct`type Person struct { Name string; Age int }`, positional vs named initialization, anonymous structs.~12 min
  2. 5.2Methods: value vs pointer receiver`func (p Person) Hello()` vs `func (p *Person) Rename(n string)`; when to use one or the other.~14 min
  3. 5.3Composition (embedding)Go has no inheritance: you compose by embedding one type inside another. Method promotion.~12 min
  4. 5.4Field tags and JSON`json:"name,omitempty"`, marshalling/unmarshalling with `encoding/json`, common mistakes.~12 min
  5. 5.5The `New...` constructor patternGo has no constructors: the convention is a `NewT(...) *T` function that validates and returns errors.~10 min

06 · Interfaces

5 lessons

Structural interfaces (no explicit implements), assertions, type switches, and the standard `Stringer` and `error` interfaces.

  1. 6.1Interfaces: defining a behaviorAn interface is a set of methods; whoever implements them satisfies it automatically (static duck typing).~12 min
  2. 6.2Type assertion`v, ok := i.(*MyT)`, the comma-ok form to avoid panics, when to prefer an assertion over a type switch.~10 min
  3. 6.3Type switch`switch v := x.(type) { case int: ... }` to dispatch on the runtime type.~10 min
  4. 6.4The Stringer interfaceImplementing `String() string` changes how `fmt.Println` represents your type.~10 min
  5. 6.5The error interface`error` is just `Error() string`; creating custom errors, `errors.Is`, `errors.As`, `fmt.Errorf("%w", err)`.~14 min

07 · Concurrency

5 lessons

Go's concurrency model: lightweight goroutines, channels for communication, `select`, sync, and context.

  1. 7.1Goroutines: lightweight parallelism`go f()`, the cost of a goroutine, why main exits without waiting, and how to synchronize.~12 min
  2. 7.2Channels: typed communication`ch := make(chan int)`, `ch <- v`, `v := <-ch`, buffered vs unbuffered channels, closing.~15 min
  3. 7.3`select`: multiplexing channelsWait for the first ready channel, the `default` case to avoid blocking, the timeout pattern with `time.After`.~12 min
  4. 7.4`sync.Mutex` and `sync.WaitGroup`When channels are not enough: protect shared state with a Mutex, wait for N goroutines with a WaitGroup.~14 min
  5. 7.5`context.Context`: cancellation and deadlinesPropagate cancellation across goroutines, `context.WithTimeout`, `ctx.Done()`, the first-parameter pattern.~14 min

08 · Essential standard library

5 lessons

The packages you'll use every day: fmt, strings, strconv, io, os, time, encoding/json.

  1. 8.1Advanced `fmt``Sprintf`, `Fprintf`, the `%+v` and `%#v` verbs, width and precision formatting, the `-` and `0` flags.~10 min
  2. 8.2`strings` and `strconv``strings.Contains/Split/Join/TrimSpace`, `strconv.Itoa/Atoi/ParseInt/FormatFloat`.~12 min
  3. 8.3`io` and `os`: files and streams`os.Open/Create/ReadFile/WriteFile`, the `io.Reader/Writer` interfaces, the `defer f.Close()` pattern.~14 min
  4. 8.4The `time` package`time.Now()`, durations, parsing with the reference layout `2006-01-02 15:04:05`, timers and tickers.~12 min
  5. 8.5`encoding/json``json.Marshal/Unmarshal`, struct tags, `json.Decoder/Encoder` for streams, parsing errors.~14 min

09 · Tests, modules, and tooling

5 lessons

The `go test` tool, table-driven tests, benchmarks, dependency management with `go mod`, and build tags.

  1. 9.1The `testing` package`*_test.go` files, `TestXxx(t *testing.T)` functions, `t.Error` vs `t.Fatal`, `go test ./...`.~12 min
  2. 9.2Table-driven testsThe idiomatic pattern: a slice of anonymous structs with inputs and expected outputs, `t.Run(name, ...)` for sub-tests.~14 min
  3. 9.3Benchmarks and profiles`BenchmarkXxx(b *testing.B)` functions, the `for i := 0; i < b.N; i++` loop, `go test -bench=.`.~12 min
  4. 9.4Go modules`go mod init`, `go get`, semantic import versioning, the `go.sum` lockfile, `go mod tidy`.~12 min
  5. 9.5Build constraints and tagsThe `//go:build ...` directive for cross-platform builds, separating test/integration code, real-world examples.~10 min

10 · Idiomatic practice

5 lessons

Naming, advanced error handling, generics (Go 1.18+), and two mini-projects: a CLI and an HTTP server.

  1. 10.1Naming conventions and stylePascalCase for exports, camelCase for locals, short names in short scopes, `gofmt` is non-negotiable.~10 min
  2. 10.2Idiomatic error handlingSentinel errors (`io.EOF`), custom errors with `Unwrap`, wrapping with `%w`, when to use `panic`.~14 min
  3. 10.3Generics (Go 1.18+)Type parameters `func Map[T, U any](s []T, f func(T) U) []U`, constraints (`comparable`, custom), trade-offs.~15 min
  4. 10.4Mini-project: a CLI with flagsThe `flag` package, commands and sub-commands, exit codes, `log` vs `fmt` for output.~18 min
  5. 10.5Mini-project: an HTTP server`net/http`, minimal handler and router, middleware as decorators, graceful shutdown with context.~18 min