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

Properly handling of enum imports #839

Merged
merged 4 commits into from
Apr 24, 2023
Merged

Conversation

wjiec
Copy link
Contributor

@wjiec wjiec commented Apr 13, 2023

  1. properly importing enums from multiple packages/namespaces with the same name(in/not in rules)
  2. reduce unnecessary duplication of import and alias

For example, a proto with this message

...
import "foo/v1/datatype.proto"
import "bar/v1/datatype.proto"
...

message CreateSomethingRequest {
  foo.v1.Foo.FooType foo_type = 1 [(validate.rules).enum = {in: [1, 2, 3, 4]}];
  bar.v1.Bar.BarType bar_type = 2 [(validate.rules).enum = {not_in: [1, 2, 3, 4]}];
}

and run go vet ./... in generated code

# example.com/buf-pgv/zoo/api/v1
vet: zoo/api/v1/zoo.pb.validate.go:187:46: undeclared name: v1

reduce unnecessary duplication of import and alias
@CLAassistant
Copy link

CLAassistant commented Apr 13, 2023

CLA assistant check
All committers have signed the CLA.

@elliotmjackson elliotmjackson changed the title go: properly handling of enum imports Properly handling of enum imports Apr 13, 2023
@rodaine
Copy link
Member

rodaine commented Apr 20, 2023

Thanks for the patch, @wjiec! Can you add a test case to the harness so that we can ensure this doesn't regress?

@rodaine rodaine added Bug Reports and/or fixes a bug Go Go language support labels Apr 20, 2023
@wjiec
Copy link
Contributor Author

wjiec commented Apr 21, 2023

Thanks for the patch, @wjiec! Can you add a test case to the harness so that we can ensure this doesn't regress?

Okay, I'll add some test cases later in the week.

@wjiec
Copy link
Contributor Author

wjiec commented Apr 22, 2023

Hi @rodaine, I've added some test cases to the PR

Copy link
Member

@rodaine rodaine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the patch!

@rodaine rodaine merged commit a3c8c99 into bufbuild:main Apr 24, 2023
@wjiec wjiec deleted the bugfix/enum-import branch April 25, 2023 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reports and/or fixes a bug Go Go language support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants