Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@sixstone-qq

Description

@sixstone-qq

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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions