protogetter icon indicating copy to clipboard operation
protogetter copied to clipboard

Disallow Get on fields that are a part of a `oneof`

Open achew22 opened this issue 1 year ago • 1 comments

Is it possible to instruct the linter to error on cases where you're getting one of the fields inside of a oneof?

For example:

message Foo {
  oneof bar {
    string baz = 1;
    string quix = 2;
  }
}

I would like to make it a lint error to call GetBaz and GetQuix directly in favor of always doing a type switch on the output of GetBar(). I don't see a documented way to do that but was curious if such a thing was possible.

Thanks so much!

achew22 avatar Apr 19 '24 17:04 achew22

Thank you for your interest in the project.

I think we can make an optional setting for this case. I'll see what I can do as soon as I can.

Thanks for the idea!

ghostiam avatar Apr 19 '24 17:04 ghostiam