8000 ST1003: ignore implementations of interfaces from generated code · Issue #1702 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

ST1003: ignore implementations of interfaces from generated code #1702

Open

Description

@ainar-g

Congrats with the new release!

Compiled with Go version: go1.26.0
Main module:
        honnef.co/go/tools@v0.7.0 (sum: h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=)
Dependencies:
        github.com/BurntSushi/toml@v1.6.0 (sum: h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=)
        golang.org/x/exp/typeparams@v0.0.0-20260218203240-3dfff04db8fa (sum: h1:6Wi43P0isP8Nl8D4qJmA3VC4FswVH0RJkr5cauo67SQ=)
        golang.org/x/mod@v0.33.0 (sum: h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=)
        golang.org/x/sync@v0.19.0 (sum: h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=)
        golang.org/x/tools@v0.42.0 (sum: h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=)

Code generators like protobuf will often create code that doesn't comply with the Go naming conventions. For example, a protobuf field like user_id will be turned into UserId. The same goes for gRPC method names, that is things like getUserById.

In order to implement the interfaces that gRPC generates, users need to define their own methods, but staticcheck currently triggers ST1003 on them, even when a check like

var _ generatedpb.UserServer = (*myUserServer)(nil)

is present.

For some examples, see:

If staticcheck could see that the interface being implemented is from an autogenerated file, the lint:ignore directives wouldn't be necessary.

Activity

  1. dominikh commented on Feb 26, 2026

    @dominikh
    Owner

    If staticcheck could see that the interface being implemented is from an autogenerated file, the lint:ignore directives wouldn't be necessary.

    I think we can go a step further and do this for all interfaces, not just generated ones. If the interface isn't generated and you're in control of it, we'll flag the offending name there. In all other cases, the name really isn't up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0