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

plugin.proto and descriptor.proto contains the wrong go_package #1289

Closed
dcaiafa opened this issue Mar 3, 2016 · 2 comments
Closed

plugin.proto and descriptor.proto contains the wrong go_package #1289

dcaiafa opened this issue Mar 3, 2016 · 2 comments

Comments

@dcaiafa
Copy link

dcaiafa commented Mar 3, 2016

plugin.proto's go_package is currently set to "plugin_go". It should be set to "compiler" because protoc-gen-go will place generated files into google/protobuf/compiler.

Similarly, descriptor.proto's go_package is currently set to "descriptor". It should be set to "protobuf".

In 2.6.1, both proto files contained no go_package statement. While not ideal, this at least allowed the package name to be specified in the --go_out=import_path parameters. In 3.0.0, it's currently impossible (to the best of my knowledge) to generate valid Go for plugin.proto and descriptor.proto without modifications.

@xfxyjwf xfxyjwf added the go label Jul 23, 2016
@haberman
Copy link
Member

haberman commented Mar 8, 2017

@neild could you weigh in on this? Should we change go_package in these .proto files?

@neild
Copy link
Contributor

neild commented Mar 10, 2017

(Sorry for the delay, traveling.)

Here's what I'm seeing for descriptor.proto:
option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";

That looks right to me. (The /protoc-gen-go/ is pretty unfortunate, but there are historical reasons for it.)

plugin.proto's go_package looks wrong, though:
option go_package = "plugin_go";

That should either be "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go" or "github.com/golang/protobuf/protoc-gen-go/plugin;plugin". The former matches the pregenerated in the Go protobuf repo, but the latter is the better choice if we don't worry about compatibility.

To expand on that: The import path for the generated package for plugin.proto is "github.com/golang/protobuf/protoc-gen-go/plugin". By Go convention, we would expect the package name to be the last component of the import path: "plugin". However, the generated package in the github.com/golang/protobuf repo is using the package name "plugin_go".

If we change the name to "plugin", we break anyone depending on the existing name. I don't know whether anyone does depend on it.

I'm inclined to say that we should stick with the existing, unfortunate, package name, in which case the go_package option should be set to "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go". I'm happy to hear arguments for changing the package name, however.

haberman added a commit to haberman/protobuf that referenced this issue Mar 16, 2017
bithium pushed a commit to bithium/protobuf that referenced this issue Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants