Go 1.13 introduced the errors.Is function to check if an error contains a target error in its chain:
err := fmt.Errorf("access denied: %w", ErrPermi