How to Use errors.Is in Go

Use errors.Is to check if an error matches a specific target or wraps it in Go.

Use errors.Is(err, target) to check if err is equal to target or wraps it, returning a boolean result. This function traverses the error chain to find matches even when the target error is nested inside a wrapped error.

if errors.Is(err, ErrInsecurePath) {
    // Handle the specific error
}