proto

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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