Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Warning about comparisons for indirect errors #55

@kolyshkin

Description

@kolyshkin

The following code produces no warnings (since v1.4.4, which has #10 fixed).

func CompareUnixErrors() {
        if err := unix.Rmdir("somepath"); err != unix.ENOENT {
                fmt.Println(err)
        }
}

but if we wrap unix.Rmdir into a function:

func rmdir(path string) error {
        return unix.Rmdir(path)
}

func CompareUnixErrors() {
        if err := rmdir("somepath"); err != unix.ENOENT {
                fmt.Println(err)
        }
}

we still get the warning:

unexpected diagnostic: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions