proto

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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

func CompileProtos(protoFiles, importPaths []string) (*Schema, error)

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

func LoadDescriptorSetFile(path string) (*Schema, error)

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 NewSchema

func NewSchema() *Schema

NewSchema creates an empty schema.

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

func (s *Schema) ListMessages() []string

ListMessages returns all message type names.

func (*Schema) ListServices

func (s *Schema) ListServices() []string

ListServices returns all service names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL