Inspectopedia
 
2024.3

Incorrect usage of the 'errors.As' function

Warning
Reliability
New
Last modified: 03 December 2024

Reports calls of the errors.As function when the second argument is not a pointer to an interface or to a type that implements an error.

Such calls panic at runtime.

For more information about the As function, refer to func As at go.dev.

Example:

After the Prepend '&' quick-fix is applied:

This inspection only reports if the language version is 1.13 or higher.