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.

disable comparison linter for errors from golang.org/x/sys/unix #10

@kolyshkin

Description

@kolyshkin

Functions from the golang.org/x/sys/unix package wraps its error, always returning bare errno, and so it's OK to use direct error comparison.

Example:

err := unix.Rmdir(path)
    if err == nil || err == unix.ENOENT {
    return nil
}

On the above code, the linter says:

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

For a package that uses a lot of unix functions, it's a burden to annotate all such code as the above example with //nolint:errorlint // unix errors are bare, but this is exactly what I had to do in runc: opencontainers/runc@56e4780

Surely, the alternative is to switch to errors.Is(err, unix.ENOENT) and the like, but in the particular case it seems redudnant.

Would be nice to have comparison linter to add an exclusion for errors returned from golang.org/x/sys/unix.* functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions