Backend development

Stage 1 · Lesson 3 of 10

Errors as values

Your language and how HTTP works

Go has no exceptions for ordinary failures. Instead, Go treats . A function that can fail returns an error as its last value, and the caller checks if err != nil straight away.

As an error travels up, wrap it with context using fmt.Errorf("load order %d: %w", id, err). Inspect it later with errors.Is and errors.As. For example, you can spot sql.ErrNoRows and turn it into a .

Use defer to close files and connections when a function ends. Save panic for truly unrecoverable bugs. The explicit checks feel wordy at first, but they make every failure path visible.

Common trapignoring an error with _ or returning it with no context, which leaves "connection refused" in the logs and no idea where it came from.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with

  • CourseFree
    A Tour of Go

    The Go Authors · Beginner

    The official interactive tour: basics, methods, interfaces, generics and concurrency

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Short runnable examples to look up while you write: errors, JSON, goroutines, testing

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?