Skip to content

🚫 Go linter that forbids inline error handling (if err := ...) — because your function deserves more attention.

License

Notifications You must be signed in to change notification settings

AlwxSin/noinlineerr

Repository files navigation

noinlineerr

A Go linter that forbids inline error handling using if err := ...; err != nil.


Why?

Inline error handling in Go can hurt readability by hiding the actual function call behind error plumbing. We believe errors and functions deserve their own spotlight.

Instead of:

if err := doSomething(); err != nil {
    return err
}

Prefer the more explicit and readable:

err := doSomething()
if err != nil {
    return err
}

Install

go install github.com/AlwxSin/noinlineerr/cmd/noinlineerr@latest

Usage

As a standalone tool

noinlineerr ./...

⚠️ Note: The linter detects inline error assignments only when the error variable is explicitly typed or deducible. It doesn't handle dynamically typed interfaces (e.g., foo().Err() where Err() returns an error via an interface).


Development

Run tests:

go test ./...

Test data lives under testdata/src/...


Contributing

PRs are welcome. Let's make Go code cleaner, one err at a time.

About

🚫 Go linter that forbids inline error handling (if err := ...) — because your function deserves more attention.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy