Skip to content
masterclass Buddy

Go · Function

errors.New

errors.New creates an error from a text message. Each call returns a distinct error value, so reuse a sentinel error when callers need to identify that condition.

Last updated

Syntax

func New(text string) error

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • fmt.Errorf
  • errors.Is
  • errors.As
  • errors.AsType
  • errors.Join
  • errors.Unwrap

Source: errors package - errors - Go Packages. Checked 2026-11-03.