Skip to content

How do I handle generating code with Protobuf definitions that share dependencies and plugins that generate all code to the same package and expect the same package name? #1113

Answered by doriable
doriable asked this question in Q&A
Discussion options

You must be logged in to vote

Full example available at: https://github.com/mfridman/buf-generate-twirp-go

To start, when you generate, you can use the --include-imports flag in order to ensure that you are including the necessary dependencies. However, you'll find that you may get a conflict:

$ buf generate --include-imports --template buf.gen.yaml buf.build/acme/petapis

error:files have conflicting go_package settings, must be the same: "money" and "paymentv1alpha1"

petapis is dependent paymentapis and both are dependent on googleapis.

The workaround here is to generate the dependent modules (in this case, paymentapis) separately with a different buf.gen.yaml template that only contains the Go plugin:

# generate G…

Replies: 1 comment

Comment options

doriable
May 6, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by doriable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant