Closed pcruz7 closed 6 years ago
Yep, you can use option go_package
to set the import path that generated go code should use when referencing your Proto C
file.
This is laid out in https://github.com/twitchtv/twirp/blob/master/protoc-gen-twirp/generator.go#L280-L290:
importPath := path.Dir(goFileName(def.File))
The goFileName
function will prefer to use the go_package
option's value for the import path, and will fall back to using the path to the file on disk (as you found).
The right way to do this is for Proto C
to include a line like this:
syntax = "proto3";
package pcruz7.protoc; // or whatever
// replace with whatever import path you want:
option go_package = "github.com/pcruz7/somerepo/protoc";
This will at least decouple the import lines in generated .twirp.go
and .pb.go
files from how you invoke protoc
and how you write imports in .proto
files, so you can maybe work things into better shape for the JS generator.
Hello,
First of all thank you for this framework and all your work in it!
This issue is only to find out how to go about with the following issue: I have 3 proto files, related in terms of use case (let's call them:
Proto A
,Proto B
andProto C
).Both
Proto A
andProto B
make use of a message format inProto C
, so in both files I included the following line:Which generates this output:
the problem is that these proto files are also generated for JS. Which in turn return the following error:
I've tried setting the
--proto_path
parameter and removing thegolang_path
, but to no avail since the generation of the go import only mirrors the import in the proto file.Is there a workaround for this?