Skip to content

ST1003: ignore implementations of interfaces from generated code #1702

@ainar-g

Description

@ainar-g

Congrats with the new release!

Compiled with Go version: go1.26.0
Main module:
        honnef.co/go/[email protected] (sum: h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=)
Dependencies:
        github.com/BurntSushi/[email protected] (sum: h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=)
        golang.org/x/exp/[email protected] (sum: h1:6Wi43P0isP8Nl8D4qJmA3VC4FswVH0RJkr5cauo67SQ=)
        golang.org/x/[email protected] (sum: h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=)
        golang.org/x/[email protected] (sum: h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=)
        golang.org/x/[email protected] (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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions