---
source: https://iinventedlight.com/library/notes/go-errors.md
title: "errors: create, wrap, and inspect Go errors"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go, errors package reference; Go, errors/errors.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-errors"
tags: [go, errors, wrap, is, as]
client: Librarian
sources:
  - id: S1
    title: "errors package reference"
    publisher: Go
    url: https://pkg.go.dev/errors
    accessed: 2026-11-23
    license: "BSD-3-Clause"
  - id: S2
    title: "errors/errors.go source"
    publisher: Go
    url: https://go.dev/src/errors/errors.go
    accessed: 2026-11-23
    license: "BSD-3-Clause"
---
# errors: create, wrap, and inspect Go errors
**Answer:** Package errors implements functions to manipulate errors. New creates an error whose only content is a text message. An error wraps another error when Unwrap returns that error. Is, As, and Join inspect or combine errors.

## Creating and wrapping

This package implements functions that manipulate errors.

New builds an error that holds only a text message.

Wrapping is available when the error's type has an Unwrap method.

If that method returns a non-nil error w, or a slice that contains w, then the first error wraps w.

## Inspection helpers

The package provides func Is(err, target error) bool, func As(err error, target any) bool, and func Join(errs ...error) error.

Is takes an err and a target error and returns a bool.

As looks up the first error in a chain that matches a target type.

Join returns one error that wraps several given errors.

## See also

- [go-fmt](https://iinventedlight.com/library/notes/go-fmt/)
- [go-testing](https://iinventedlight.com/library/notes/go-testing/)
- [go-context](https://iinventedlight.com/library/notes/go-context/)

## Claims

- id: C1
  claim: Package errors implements functions to manipulate errors.
  source: S1
  evidence: "Package errors implements functions to manipulate errors."

- id: C2
  claim: New creates an error whose only content is a text message.
  source: S1
  evidence: "creates errors whose only content is a text message"

- id: C3
  claim: An error wraps another error when Unwrap returns it.
  source: S2
  evidence: "then we say that e wraps w"

- id: C4
  claim: The package provides Is, As, and Join.
  source: S1
  evidence: "func Join(errs ...error) error"

## Sources

- [S1] errors package reference. Go. https://pkg.go.dev/errors . License: BSD-3-Clause. Accessed 2026-11-23.

- [S2] errors/errors.go source. Go. https://go.dev/src/errors/errors.go . License: BSD-3-Clause. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, errors package reference; Go, errors/errors.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
