protobundle

package
v3.23.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxEdition = 2024

Variables

This section is empty.

Functions

func Compile

Compile produces a FileDescriptorSet from discovered proto files. The returned descriptor set contains all compiled files and their transitive dependencies, sorted by file name for deterministic output.

func Decode

func Decode(compressed []byte) (*descriptorpb.FileDescriptorSet, error)

Decode decompresses S2-compressed data and unmarshals a FileDescriptorSet. This is the counterpart of Write with ".pbs" extension, intended for use at load time.

func Write

func Write(fds *descriptorpb.FileDescriptorSet, path string) error

Write marshals the FileDescriptorSet and writes it atomically to path. If the path ends with ".pbs", the payload is compressed with S2 (block mode, best compression). Otherwise (".pb") the raw protobuf bytes are written. It writes to a temporary file first, then renames to ensure atomicity.

Types

type CompileParams

type CompileParams struct {
	Roots []string // import roots for resolver
	Files []string // relative paths to compile
}

CompileParams configures the protocompile compilation.

type DiscoverParams

type DiscoverParams struct {
	Roots      []string // import root dirs, priority order
	Include    []string // glob patterns (default: **/*.proto)
	Exclude    []string // glob patterns to skip
	MaxEdition int      // highest supported edition year; 0 → DefaultMaxEdition
}

DiscoverParams configures proto file discovery across roots.

type DiscoverResult

type DiscoverResult struct {
	// Files maps relative path -> absolute path.
	// On conflict: file with newer syntax wins (edition "2024" > edition "2023" > ... > proto3 > proto2);
	// among equal syntax, first root wins.
	Files map[string]string
	// Skipped lists relative paths that were shadowed by deduplication.
	Skipped []string
	// UnsupportedEdition lists relative paths of files skipped because their edition exceeds MaxEdition.
	UnsupportedEdition []string
}

DiscoverResult holds discovered proto files ready for compilation.

func Discover

func Discover(params DiscoverParams) (*DiscoverResult, error)

Discover walks roots and returns deduplicated proto files. Only .proto files are collected; all other content is ignored. Files with edition above MaxEdition (default DefaultMaxEdition) are skipped.

func (*DiscoverResult) Sorted

func (r *DiscoverResult) Sorted() []string

Sorted returns the file relative paths in sorted order.

Jump to

Keyboard shortcuts

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