User Tools

Site Tools


go:errors:start

Error Handling

What is it?

In Go, errors are values returned from functions. The common pattern is: return `(result, error)` and check `if err != nil`.

What is it used for?

  • Report failures without exceptions.
  • Keep control flow explicit.
  • Add context to failures (wrapping) and handle them appropriately.

Core topics

Hard words (English)

  • explicit /ɪkˈsplɪsɪt/: tường minh
  • failure /ˈfeɪljər/: lỗi/thất bại
  • context /ˈkɑːntekst/: ngữ cảnh
go/errors/start.txt · Last modified: by phong2018