errors

Core
import "errors"

Implements functions for creating and inspecting error values.

Example

package main

import (
    "errors"
    "fmt"
)

var ErrNotFound = errors.New("not found")

func main() {
    err := fmt.Errorf("user: %w", ErrNotFound)
    fmt.Println(errors.Is(err, ErrNotFound))  // true
}

Key Types & Functions

NewIsAsUnwrapJoin

About errors

The errors package (imported as errors) belongs to the Core category of Go packages. Implements functions for creating and inspecting error values.

Go's standard library is one of the language's greatest strengths, providing production-ready implementations for networking, cryptography, encoding, I/O, and more. The errors package follows Go's philosophy of simplicity and composability — small, focused packages that combine through interfaces like io.Reader and io.Writer.

When using errors in production, follow Go best practices: handle errors explicitly, use context for cancellation and timeouts, prefer composition over inheritance, and write table-driven tests. The Go documentation at pkg.go.dev provides comprehensive API references and examples for every exported type and function.

Related Packages