Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_prefix shouldn't be used for non-proto packages #181

Closed
zellyn opened this issue May 3, 2016 · 6 comments
Closed

import_prefix shouldn't be used for non-proto packages #181

zellyn opened this issue May 3, 2016 · 6 comments

Comments

@zellyn
Copy link
Contributor

zellyn commented May 3, 2016

We're trying to figure out how to generate our protos into a subdirectory, so they don't collide with existing code. We also have a mix of our protos, and a few externally-created protos (eg. proto descriptors, etc.)

It almost works to use import_prefix to add a "protos" subdirectory on the front of every proto import.

However, the import_prefix is also applied to three normal Go package imports: proto runtime, context package, grpc package.

It's difficult to imagine a scenario where one would want to try to import golang.org/x/net/context from inside a generated-protobuf directory, especially given the vendor/ folder semantics.

@zellyn
Copy link
Contributor Author

zellyn commented May 3, 2016

/cc @jhump

@warebot
Copy link

warebot commented Jul 22, 2016

+1 To this proposal.
Ended up with "sed" hacks to make this work.

@zombiezen
Copy link
Contributor

import_prefix predates the vendor/ subdirectory. I agree it's confusing, but changing its functionality now could cause breakage to people's build processes. One possibility is that we could introduce a new flag that has the functionality you describe, but I think that such a design proposal would need to also consider how this would interact with the go_package option.

@jmasonISP
Copy link

jmasonISP commented Sep 21, 2016

+1 To this proposal as well. In its current state, import_prefix is unusable for us because it is added to the import of proto runtime and other packages. My short term solution will be to update the proto-gen-go plugin to omit using the import_prefix for importing the proto runtime et al.

I am also OK with adding a new parameter the performs the desired "proper" import prefix.

Edit: I've fallen back to using the go_package option instead of using a modified version of proto-gen-go

@neild
Copy link
Contributor

neild commented Feb 16, 2018

I really don't understand why you'd ever want the current behavior of import_prefix. However, I also don't understand why you'd want to use import_prefix at all; what does it give that you can't get in a better fashion by including a go_package option in each source file to specify the correct import path?

I'm inclined to say that we should deprecate or remove import_prefix rather than tweaking it.

@dsnet
Copy link
Member

dsnet commented Mar 8, 2018

The import_prefix flag is considered deprecated. The recommended approach is to specify a go_package option.

@dsnet dsnet closed this as completed Mar 8, 2018
@golang golang locked as resolved and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants