Modern named return linter?

What’s a Go 1.24.1 compatible named return linter?

Neither golangci-lint (nakedret, nonamedreturn), lint-naked-returns, nor returnstyles have updated their x dependencies to account for breaking compilation changes.

As an aside, Go should weaken its backwards compatibility guarantees, or else merge the x libraries into stdlib, for futureproofing.

As of late April 2025, a readily available Go 1.24.1 compatible named return linter is likely unavailable due to outdated x dependencies in popular options like golangci-lint and returnstyles. Your best bet is to monitor these linters for updates on their GitHub repositories or temporarily use an older Go version if strict 1.24.1 compatibility isn’t immediately necessary. Building a custom linter is a more involved alternative. The broader issue of Go’s backward compatibility and the x libraries is a known trade-off in the Go ecosystem.

  1. A linter that enforces named return values (in a language like Go)?
  2. A modern linter that checks for issues with named return values?
  3. A linter named “Named Return” (perhaps a specific tool)?
  4. Something else entirely?

In general, here’s a quick overview that might hit what you’re asking:


:brain: What Are Named Return Values?

In languages like Go, you can declare return values by name in the function signature:

go

CopyEdit

func calculate(a int, b int) (sum int, diff int) {
    sum [=](https://hell-starsclothing.com/) a + b
    diff = a - b
    return // implicit return of named values
}

This can be useful, but also confusing or error-prone if misused — which is why linters may warn about them.


:magnifying_glass_tilted_left: Linters for Named Returns

If you’re looking for linters that deal with named returns (especially in Go):

1. Staticcheck

  • A powerful Go linter.
  • Flags unnecessary named return values or warns when they’re used in confusing ways.
  • https://staticcheck.io/

2. golangci-lint

  • Aggregates multiple linters.
  • Includes staticcheck and others.
  • Can be configured to enforce best practices regarding named returns.

:test_tube: Example Rule You Might Want

  • Warn when named return values are declared but not used.
  • Warn when named return values are used without an explicit return (which might confuse readers).
  • Ban named return values entirely unless justified.

I’m asking because those very linters are inoperable with each successive Go release. The x dependencies introduce breaking changes which the linter maintainers are lax on keeping up with.