---
description: "Suggest errors.AsType over errors.As with a target pointer (Go 1.26)"
scope: "tool:edit(*.go), tool:write(*.go)"
interruptMode: never
astCondition:
  - "errors.As($ERR, &$T)"
---

`errors.As` with a `var t *MyErr; errors.As(err, &t)` dance is replaced by the generic
`errors.AsType` (Go 1.26): `t, ok := errors.AsType[*MyErr](err)`. Type-safe, fewer allocations,
no two-step target. `AsType` returns `(T, bool)`; drop the `ok` when you only need the value.
