compiler

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RelativePathFromImportPaths added in v0.5.2

func RelativePathFromImportPaths(protoPath string, importPaths []string) (string, error)

Types

type Compiler

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

Compiler provides a way to generate file descriptors from a Protocol Buffers file without relying on protoc command. This allows you to do things like validate proto files without relying on protoc.

func New

func New() *Compiler

New creates compiler instance.

func (*Compiler) Compile

func (c *Compiler) Compile(ctx context.Context, file *source.File, opts ...Option) ([]*descriptorpb.FileDescriptorProto, error)

Compile compile the target Protocol Buffers file and produces all file descriptors.

type CompilerError

type CompilerError struct {
	Err        error
	ErrWithPos []reporter.ErrorWithPos
}

CompilerError has error with source position.

func (*CompilerError) Error

func (e *CompilerError) Error() string

type Option

type Option func(*Compiler)

Option represents compiler option.

func ImportPathOption

func ImportPathOption(path ...string) Option

ImportPathOption used to add a path to reference a proto file. By default, only the directory where the starting file exists is added to the import path.

func ManualImportOption added in v0.3.3

func ManualImportOption() Option

ManualImportOption stops importing `grpc/federation/federation.proto` file and its dependencies By default if `grpc/federation/federation.proto` file and its dependencies do not exist, automatically imports it. The version of the proto file is the same as the version when the compiler is built.

Jump to

Keyboard shortcuts

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