Code Monkey home page Code Monkey logo

Comments (5)

neild avatar neild commented on June 2, 2024 1

There are three different elements here (actually four, of which you mentioned three):

  • the protobuf package name;
  • the Go package import path;
  • the Go package name; and
  • the file name of the source file.

google.protobuf seems like a good name for the protobuf package, since this is already well-established as being under the ownership of the protobuf project. I don't know why cpp_features.proto and java_features.proto are using pb; that doesn't seem like a good name at all. Possibly these are intended to be strictly internal to the code generator, in which case the name doesn't matter? It doesn't seem likely that these will remain purely internal, though. Someone should probably open an issue in the appropriate tracker to have the name changed to something better.

It looks like when go_features.proto moved from reflect/protodesc/proto (initial home, never appeared in any release AFAIK), we forgot to update the regeneration script to operate on the new location, so the generated package has the wrong name (proto, rather than gofeaturespb) and its descriptor references the old location. We should fix that and regenerate the .pb.go.

The file name is also stale ("reflect/protodesc/proto/go_features.proto"), but simply regenerating the file isn't enough. Doing so would set the name to "types/gofeaturespb/go_features.proto", which is insufficiently qualified.

The file names for the C++ and Java files are "protobuf/compiler/cpp/cpp_features.proto" and "protobuf/compiler/java/java_features.proto". Using the same pattern for Go seems reasonable. (Perhaps all three should be under "google/protobuf" instead.)

I think the clearest way to handle this is to create a new top-level directory in the https://go.googlesource.com/protobuf repo to hold public .proto files. Possibly src (short, matches the main proto repo structure), moving the file to src/protobuf/compiler/go/go_features.proto.

from protobuf.

jhump avatar jhump commented on June 2, 2024

google.protobuf seems like a good name for the protobuf package, since this is already well-established as being under the ownership of the protobuf project. I don't know why cpp_features.proto and java_features.proto are using pb; that doesn't seem like a good name at all.

This was a decision by the Protobuf team for Editions. Features are likely to appear in greater numbers in files that are "prototilled" (auto-converted from proto2 or proto3 to editions), and "pb" is a much more concise but still readable name. I was told that the internal version of go_features.proto actually uses "pb" as the package name and that I could file a bug since it is likely a Copybara misconfiguration that changed the package in the GitHub version. Cc @mkruskal-google.

The file names for the C++ and Java files are "protobuf/compiler/cpp/cpp_features.proto" and "protobuf/compiler/java/java_features.proto"

I don't think this is accurate. From what I can see in the main protobuf repo, they use "google/protobuf/cpp_features.proto" and "google/protobuf/java_features.proto".

from protobuf.

neild avatar neild commented on June 2, 2024

I don't think this is accurate. From what I can see in the main protobuf repo, they use "google/protobuf/cpp_features.proto" and "google/protobuf/java_features.proto".

I could swear that I was seeing protobuf/compiler/(lang)/lang_features.proto somewhere, and now I can't find what I was looking at. You're right, these seem to be under google/protobuf.

from protobuf.

lfolger avatar lfolger commented on June 2, 2024

Possibly these are intended to be strictly internal to the code generator, in which case the name doesn't matter?

I don't thik so because if you want to use the features defined in these, you need to import these files and use the types deffined in them. But I agree that these names seem suboptimal.

I think the clearest way to handle this is to create a new top-level directory in the https://go.googlesource.com/protobuf repo to hold public .proto files. Possibly src (short, matches the main proto repo structure), moving the file to src/protobuf/compiler/go/go_features.proto.

Thanks for the input. I agree and prepared https://go-review.googlesource.com/c/protobuf/+/579975 to address this.

from protobuf.

lfolger avatar lfolger commented on June 2, 2024

The change was submitted. This should address all of your concern. If not, feel free to reopen this issue.

from protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.