BuildBot

Go by Contrast

Errors are values

Lesson 2 of 5

Go has no try/catch — functions return a result and an error, and you check the error at every call site.

What you'll learn

  • Understand Go's error-as-value model
  • Contrast it with JS/TS try/catch and thrown exceptions
  • See why the explicit if err != nil pattern is everywhere in Go
Members only

A free account unlocks this lesson and every other one.

Runnable challenges, knowledge checks, and progress that syncs across your devices. No card needed.

Not sure yet? Try the free lesson first: Types, structs & the basics