What is the difference between errors.Is and errors.As, and how do they help when working with wrapped errors?

Last updated 20 June 2026

  • errors.Is(err, target) checks whether the error chain contains a specific sentinel value, e.g. sql.ErrNoRows.

  • errors.As(err, &target) finds the first error of a given type in the chain and assigns it to your pointer, so you can read its fields.

  • Both walk the chain via Unwrap(), which matters because wrapping with %w changes the outer value and breaks plain == comparison.

  • https://www.reddit.com/r/rust/comments/1h15md8/goodbye_rust_i_wish_you_success_but_im_back_to_c/
  • https://www.reddit.com/r/golang/comments/1gfjnzm/since_when_is_senior_golang_developer_expected_to/
All Golang interview questions