Open
Description
There is a slightly unexpected behavior stemming from the use of import public
.
When two proto files in a single package both contain public imports of the same dependency, the resulting package cannot be compiled.
What version of protobuf and what language are you using?
Version: v3.6.1
What did you do?
- create lib/lib.proto
- create api/foo.proto and include
import public "lib/lib.proto";
- create api/bar.proto and include
import public "lib/lib.proto";
What did you expect to see?
One would expect for the code generation to include at most one type-alias per package for a given public/aliased type.
type LibType = lib.LibType
What did you see instead?
api/foo.pb.go:
type LibType = lib.LibType
api/bar.pb.go:
type LibType = lib.LibType
LibType redeclared in bar.pb.go
previous declaration at foo.pb.go
proposal
generate the type aliases for all types in a given public import in a separate file. this way, the aliases will be present at most once per go package.