Skip to content

Running under Bazel creates colliding imports #172

@GauntletWizard

Description

@GauntletWizard

I have a protobuf library with many types like:

path/to/type/v1
path/to/type/v2
path/to/another_type/v1

These have non-conflicting importpaths in go, and we're using go_package options to give them unique package names as well, i.e. github.com/gauntletwizard/foo/proto/path/to/type/v1;type github.com/gauntletwizard/foo/proto/path/to/another_type/v1;another_type

Generation of the proto libraries works fine from our Makefile which simply references everything with --proto_path=./proto. However, when using the bazel proto, we get issues with conflicting import names - Both packages are imported as v1:

import (
...
v1 "github.com/gauntletwizard/foo/proto/path/to/type/v1"
v1 "github.com/gauntletwizard/foo/proto/path/to/another_type/v1"
)

This stems from the way that bazel passes in imports; Rather than importing one directory containing all source .proto files, bazel passes each .proto in an import statement:
-import 'protobuf/path/to/type/v1/types.proto=github.com/gauntletwizard/foo/path/to/type/v1'

This causes the package's path to be overridden:
https://github.com/lyft/protoc-gen-star/blob/master/lang/go/package.go#L57

Preferably, packages would be disambiguated before generating code, with colliding packages using more of their path (or hashes of their full path, or whatever). My short term fix was simply to disable that code, and it might be a quick-fix to add a compilation option to disable it as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReports and/or fixes a bugGoGo language supportGoGo [DEPRECATED]Gogo plugin support [DEPRECATED]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions