Skip to content

proto: support looking up by package #623

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

Closed
jmillikin-stripe opened this issue May 31, 2018 · 1 comment
Closed

proto: support looking up by package #623

jmillikin-stripe opened this issue May 31, 2018 · 1 comment

Comments

@jmillikin-stripe
Copy link

The proto.MessageType and proto.GetProperties functions can, together, be used to introspect the fields available to a protobuf message type identified by name. This request is for corresponding functionality that operates at the level of protobuf packages.

syntax = "proto3";
package k8s.io.some.package;

message SomeMessage { ... }
message OtherMessage { ... }

The API doesn't need to be very complex, just enough to figure out which messages are available:

type Package struct {
  Name string // "k8s.io.some.package"
}
func (*Package) MessageTypes() []reflect.Type

// []string{"k8s.io.some.package.SomeMessage", "k8s.io.some.package.OtherMessage"}
func (*Package) MessageNames() []string

Use case: I want to add type safety to an existing protobuf-compatible config system. The user-visible behavior and error messages will be much more pleasant if the code can introspect the set of messages available to a named Protobuf package.

@dsnet
Copy link
Member

dsnet commented May 31, 2018

Hi, thanks for the issue. I'm going to close this as a duplicate of #268, which is the super-bug, tracking registration improvements. What you are describing is a feature I would like to see be possible in the overhaul of registration.

@dsnet dsnet closed this as completed May 31, 2018
@dsnet dsnet changed the title Please provide introspection of registered protobuf packages proto: support looking up by package May 31, 2018
@golang golang locked 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

2 participants