Documentation
¶
Index ¶
- func JSONToProtobuf(jsonData []byte, md protoreflect.MessageDescriptor) ([]byte, error)
- func ProtobufToJSON(data []byte, md protoreflect.MessageDescriptor) ([]byte, error)
- func ProtobufToJSONCompact(data []byte, md protoreflect.MessageDescriptor) ([]byte, error)
- type ProtocError
- type ProtocNotFoundError
- type Schema
- func (s *Schema) FindMessage(name string) (protoreflect.MessageDescriptor, error)
- func (s *Schema) FindMethod(fullName string) (protoreflect.MethodDescriptor, error)
- func (s *Schema) FindService(name string) (protoreflect.ServiceDescriptor, error)
- func (s *Schema) ListMessages() []string
- func (s *Schema) ListServices() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToProtobuf ¶
func JSONToProtobuf(jsonData []byte, md protoreflect.MessageDescriptor) ([]byte, error)
JSONToProtobuf converts JSON data to protobuf binary format.
func ProtobufToJSON ¶
func ProtobufToJSON(data []byte, md protoreflect.MessageDescriptor) ([]byte, error)
ProtobufToJSON converts protobuf binary data to JSON format.
func ProtobufToJSONCompact ¶
func ProtobufToJSONCompact(data []byte, md protoreflect.MessageDescriptor) ([]byte, error)
ProtobufToJSONCompact converts protobuf binary data to compact JSON format.
Types ¶
type ProtocError ¶
type ProtocError struct {
Message string
}
ProtocError indicates protoc execution failed.
func (*ProtocError) Error ¶
func (e *ProtocError) Error() string
type ProtocNotFoundError ¶
type ProtocNotFoundError struct{}
ProtocNotFoundError indicates protoc is not installed or not in PATH.
func (*ProtocNotFoundError) Error ¶
func (e *ProtocNotFoundError) Error() string
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema holds loaded protobuf type information from descriptors.
func CompileProtos ¶
CompileProtos compiles .proto files via protoc and returns the loaded schema. protoFiles is a list of .proto file paths. importPaths is a list of directories to search for imports (-I flags to protoc).
func LoadDescriptorSetFile ¶
LoadDescriptorSetFile loads a schema from a pre-compiled FileDescriptorSet file (.pb).
func LoadFromDescriptorSet ¶
func LoadFromDescriptorSet(fds *descriptorpb.FileDescriptorSet) (*Schema, error)
LoadFromDescriptorSet loads schema from a FileDescriptorSet.
func (*Schema) FindMessage ¶
func (s *Schema) FindMessage(name string) (protoreflect.MessageDescriptor, error)
FindMessage finds a message descriptor by full name. The name can be with or without leading dot.
func (*Schema) FindMethod ¶
func (s *Schema) FindMethod(fullName string) (protoreflect.MethodDescriptor, error)
FindMethod finds a method in a service by service and method name. The format can be "package.Service/Method" or "package.Service.Method".
func (*Schema) FindService ¶
func (s *Schema) FindService(name string) (protoreflect.ServiceDescriptor, error)
FindService finds a service descriptor by full name.
func (*Schema) ListMessages ¶
ListMessages returns all message type names.
func (*Schema) ListServices ¶
ListServices returns all service names.