Documentation
¶
Index ¶
- Constants
- func Compile(ctx context.Context, params CompileParams) (*descriptorpb.FileDescriptorSet, error)
- func Decode(compressed []byte) (*descriptorpb.FileDescriptorSet, error)
- func Write(fds *descriptorpb.FileDescriptorSet, path string) error
- type CompileParams
- type DiscoverParams
- type DiscoverResult
Constants ¶
const DefaultMaxEdition = 2024
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(ctx context.Context, params CompileParams) (*descriptorpb.FileDescriptorSet, error)
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.