Help us shape the future of Go! Take the 2026 Go Developer Survey

descriptors

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package descriptors loads the protobuf descriptors that gRPC and Connect wire decoding uses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAgreement

func CheckAgreement(registry *Registry, loaded *schema.Schema) error

CheckAgreement requires matching declarations for every object message and unary method. Raw HTTP declarations may have no protobuf counterpart.

func Declarations

func Declarations(ctx context.Context, set *descriptorpb.FileDescriptorSet) (map[string]string, error)

Declarations renders one TypeScript declaration file per protobuf file, keyed by the proto file name with a .d.ts extension. Empty declarations are omitted.

func LoadDescriptorSets

func LoadDescriptorSets(config Config) (*descriptorpb.FileDescriptorSet, error)

LoadDescriptorSets merges every .pb file in the configured directory into one set. The result is empty when no directory is configured.

func Merge

Merge combines descriptor sets, sorted by file name. A file may appear in several sets if the copies differ only in metadata; the first copy is kept.

func WriteDeclarations

func WriteDeclarations(ctx context.Context, set *descriptorpb.FileDescriptorSet, dir string) error

WriteDeclarations renders the declarations for set into dir, replacing any files of the same name. Other files are left alone; symlinks cannot escape dir.

Types

type Config

type Config struct {
	// DescriptorsDir holds binary FileDescriptorSet files, each including its imports.
	DescriptorsDir string `` /* 184-byte string literal not displayed */
}

Config selects static descriptor sources.

func NewConfig

func NewConfig() Config

NewConfig returns the default descriptors configuration.

type ReflectionLoader

type ReflectionLoader struct{}

ReflectionLoader loads service descriptors from a gRPC reflection endpoint.

func NewReflectionLoader

func NewReflectionLoader() *ReflectionLoader

NewReflectionLoader constructs a gRPC reflection descriptor loader.

func (*ReflectionLoader) Load

func (loader *ReflectionLoader) Load(ctx context.Context, endpoint string) (*descriptorpb.FileDescriptorSet, error)

Load returns the descriptor set exposed by the endpoint's application services.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry resolves messages and RPC methods from a local descriptor set.

func New

func New(data []byte) (*Registry, error)

New loads a binary FileDescriptorSet containing all of its imported files.

func NewRegistry

func NewRegistry(set *descriptorpb.FileDescriptorSet) (*Registry, error)

NewRegistry loads a descriptor set containing all imported files. An empty set is valid, as services that only serve raw HTTP need no descriptors.

func (*Registry) Extensions

func (r *Registry) Extensions(message protoreflect.FullName) []protoreflect.FieldDescriptor

Extensions returns the extensions of a message declared anywhere in the set, ordered by field number.

func (*Registry) Files

func (r *Registry) Files() *protoregistry.Files

Files returns the descriptors resolved from this registry.

func (*Registry) Message

Message resolves a fully qualified protobuf message name, including nested messages.

func (*Registry) Method

Method resolves a fully qualified RPC name such as example.users.v1.UserService.ListUsers.

func (*Registry) Types

func (r *Registry) Types() *dynamicpb.Types

Types returns the dynamic types resolved from this registry.

Jump to

Keyboard shortcuts

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