Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option (go.lint).all = true; does not work for enum values imported from other package #40

Closed
sixstone-qq opened this issue Mar 11, 2021 · 1 comment · Fixed by #41 or #43
Closed
Assignees

Comments

@sixstone-qq
Copy link

Firstly, thanks a lot for this project, it's really great.

Provided awesome/v1/entity.proto:

package awesome.v1;

import "patch/go.proto";

option (go.lint).all = true;

enum MyEnum {
   MY_ENUM_UNSPECIFIED = 0;
}

It generates idiomatic Go identifiers 👍 on entity.pb.go:

const (
      MyEnumUnspecified MyEnum = 0
)

And then awesome/api/v1/api.proto:

package awesome.api.v1;

import "patch/go.proto";
import "awesome/v1/entity.proto"

option (go.lint).all = true;

message MessageWithMyEnum {
    awesome.v1.MyEnum my_enum = 0;
}

But at generate this message, it fails to use the patched identifier on api.pb.go:

func (x *MessageWithMyEnum) GetMyEnum() v1.MyEnum {
    if x != nil {
          return x.MyEnum
    }
    return v1.MY_ENUM_UNSPECIFIED
}

This is worked around with this code:

enum MyEnum {
   MY_ENUM_UNSPECIFIED = 0 [(go.value) = {name:'MyEnumUnspecified'}];
}

Thanks!

@ydnar
Copy link
Contributor

ydnar commented Mar 11, 2021

Hi, thanks for the bug report. That’s…interesting. I’ll take a look.

@ydnar ydnar self-assigned this Mar 11, 2021
ydnar added a commit that referenced this issue Mar 11, 2021
This is a test case to verify the bug in #40.
ydnar added a commit that referenced this issue Mar 11, 2021
This fixes using imported enum values renamed with (go.lint).all. Fixes #40.
ydnar added a commit that referenced this issue Mar 11, 2021
ydnar added a commit that referenced this issue Mar 11, 2021
@ydnar ydnar closed this as completed in #41 Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants