Preventing Import of Dependencies in Go Generate #3802
Replies: 1 comment 7 replies
-
So this is a little bit difficult to explain without seeing a representation of your proto sources, but hopefully the following explanation is helpful. Basically this import statement is generated because your proto sources import proto definitions from your dependency, and it needs to reference Go code for this dependency. And it is expecting that you are handling the required Go code through some kind of import. A common example from our docs is the use of In your case, you can disable the setting of the appropriate file option in your external module (assuming that it has the appropriate |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I currently push a module containing only proto files (
buf.build/shiron-dev/protoc-gen-connect-map
) to the BSR.When I include this module in the
deps
section of mybuf.yaml
file and import a proto file from that module into a proto file in my current project, the generated Go code (pb.go) produced bybuf generate
unintentionally includes an import statement forbuf.build/shiron-dev/protoc-gen-connect-map
.However,
buf.build/shiron-dev/protoc-gen-connect-map
is not a Go package, so this import statement is unnecessary.Is there a way to prevent
buf generate
from generating import statements for modules included as dependencies? I'm particularly interested in controlling import statement generation through settings inbuf.gen.yaml
.Specifically, I'd appreciate advice on the following:
buf.yaml
to prevent a specific module from influencing go generate.buf.gen.yaml
to control the generation of import statements.I will paste the contents of my
buf.yaml
andbuf.gen.yaml
files below this post. Your review of these configurations would be greatly appreciated.Thank you for your assistance.
Beta Was this translation helpful? Give feedback.
All reactions