Documentation
¶
Overview ¶
Package proto provides proto file export functionality.
Index ¶
- func ConvertFromRegistry(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto
- func ConvertToFileDescriptor(fdp *descriptorpb.FileDescriptorProto) (protoreflect.FileDescriptor, error)
- func MergeFileDescriptorSets(sets ...*descriptorpb.FileDescriptorSet) *descriptorpb.FileDescriptorSet
- type ExportOption
- func WithCSharpNamespace(ns string) ExportOption
- func WithGoPackage(pkg string) ExportOption
- func WithJavaMultipleFiles(multiple bool) ExportOption
- func WithJavaOuterClass(className string) ExportOption
- func WithJavaPackage(pkg string) ExportOption
- func WithObjcClassPrefix(prefix string) ExportOption
- func WithPhpMetadataNamespace(ns string) ExportOption
- func WithPhpNamespace(ns string) ExportOption
- func WithPythonPackage(pkg string) ExportOption
- func WithRubyPackage(pkg string) ExportOption
- type ExportOptions
- type Exporter
- type LanguageOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertFromRegistry ¶
func ConvertFromRegistry(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto
ConvertFromRegistry converts from protoreflect.FileDescriptor to FileDescriptorProto. This is useful when working with protobuf registry files.
func ConvertToFileDescriptor ¶
func ConvertToFileDescriptor(fdp *descriptorpb.FileDescriptorProto) (protoreflect.FileDescriptor, error)
ConvertToFileDescriptor converts a FileDescriptorProto to protoreflect.FileDescriptor. This is a helper function for cases where you need the intermediate representation.
func MergeFileDescriptorSets ¶
func MergeFileDescriptorSets(sets ...*descriptorpb.FileDescriptorSet) *descriptorpb.FileDescriptorSet
MergeFileDescriptorSets merges multiple FileDescriptorSets into one.
Types ¶
type ExportOption ¶ added in v0.5.0
type ExportOption func(*ExportOptions)
ExportOption is a functional option for configuring ExportOptions.
func WithCSharpNamespace ¶ added in v0.5.0
func WithCSharpNamespace(ns string) ExportOption
WithCSharpNamespace sets the C# namespace option for exported proto files.
func WithGoPackage ¶ added in v0.5.0
func WithGoPackage(pkg string) ExportOption
WithGoPackage sets the Go package option for exported proto files.
func WithJavaMultipleFiles ¶ added in v0.5.0
func WithJavaMultipleFiles(multiple bool) ExportOption
WithJavaMultipleFiles sets the Java multiple files option for exported proto files.
func WithJavaOuterClass ¶ added in v0.5.0
func WithJavaOuterClass(className string) ExportOption
WithJavaOuterClass sets the Java outer classname option for exported proto files.
func WithJavaPackage ¶ added in v0.5.0
func WithJavaPackage(pkg string) ExportOption
WithJavaPackage sets the Java package option for exported proto files.
func WithObjcClassPrefix ¶ added in v0.5.0
func WithObjcClassPrefix(prefix string) ExportOption
WithObjcClassPrefix sets the Objective-C class prefix option for exported proto files.
func WithPhpMetadataNamespace ¶ added in v0.5.0
func WithPhpMetadataNamespace(ns string) ExportOption
WithPhpMetadataNamespace sets the PHP metadata namespace option for exported proto files.
func WithPhpNamespace ¶ added in v0.5.0
func WithPhpNamespace(ns string) ExportOption
WithPhpNamespace sets the PHP namespace option for exported proto files.
func WithPythonPackage ¶ added in v0.5.0
func WithPythonPackage(pkg string) ExportOption
WithPythonPackage sets the Python package option for exported proto files.
func WithRubyPackage ¶ added in v0.5.0
func WithRubyPackage(pkg string) ExportOption
WithRubyPackage sets the Ruby package option for exported proto files.
type ExportOptions ¶
type ExportOptions struct {
// IncludeComments adds comments to the exported proto files
IncludeComments bool
// SortElements sorts messages, fields, etc. alphabetically
SortElements bool
// Indent configures the indentation string (default: 2 spaces)
Indent string
// LanguageOptions contains language-specific options for the proto file
LanguageOptions LanguageOptions
}
ExportOptions configures proto file export.
func DefaultExportOptions ¶
func DefaultExportOptions() ExportOptions
DefaultExportOptions returns default export options.
func (*ExportOptions) ApplyOptions ¶ added in v0.5.0
func (opts *ExportOptions) ApplyOptions(options ...ExportOption)
ApplyOptions applies the given options to ExportOptions.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter handles proto file export operations.
func NewExporter ¶
func NewExporter(opts *ExportOptions) *Exporter
NewExporter creates a new proto exporter.
func (*Exporter) ExportFileDescriptorProto ¶
func (e *Exporter) ExportFileDescriptorProto(fdp *descriptorpb.FileDescriptorProto) (string, error)
ExportFileDescriptorProto exports a single proto file.
func (*Exporter) ExportFileDescriptorSet ¶
func (e *Exporter) ExportFileDescriptorSet(fdset *descriptorpb.FileDescriptorSet) (map[string]string, error)
ExportFileDescriptorSet exports all proto files from a FileDescriptorSet.
func (*Exporter) ExportToZip ¶
func (e *Exporter) ExportToZip(fdset *descriptorpb.FileDescriptorSet) ([]byte, error)
ExportToZip exports all proto files to a ZIP archive.
type LanguageOptions ¶ added in v0.5.0
type LanguageOptions struct {
// Go options
GoPackage string
// Java options
JavaPackage string
JavaOuterClass string
JavaMultipleFiles bool
// C# options
CSharpNamespace string
// PHP options
PhpNamespace string
PhpMetadataNamespace string
// Ruby options
RubyPackage string
// Python options (usually not needed, but can be specified)
PythonPackage string
// Objective-C/Swift options
ObjcClassPrefix string
}
LanguageOptions contains language-specific options for proto files.