Skip to content
masterclass Buddy

Go · Function

errors.As

errors.As checks whether an error or one of its wrapped errors has a requested type. It stores the matching error in a target variable when it finds one.

Last updated

Since
Go 1.13

Syntax

func As(err error, target any) bool

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

Subscribe
  • errors.Is
  • errors.Unwrap
  • fmt.Errorf
  • Unwrap

Source: Working with Errors in Go 1.13 - The Go Programming Language. Checked 2026-11-03.