Skip to content

protoc-gen-go: cannot compile package when import public example.proto in is present in two or more files #810

Open
@btc

Description

@btc

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?

  1. create lib/lib.proto
  2. create api/foo.proto and include import public "lib/lib.proto";
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions