protoc

package
v0.0.0-...-a8f2654 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package protoc contains helpers for running `protoc` using protos files stored in the Go source tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(ctx context.Context, p *CompileParams) error

Compile runs protoc over staged inputs.

Types

type CompileParams

type CompileParams struct {
	Inputs                 *StagedInputs     // a staging directory with proto files
	OutputDescriptorSet    string            // a path to write the descriptor set to
	GoEnabled              bool              // true to use protoc-gen-go plugin
	GoPackageMap           map[string]string // maps a proto path to a go package name
	GoDeprecatedGRPCPlugin bool              // true to use deprecated grpc protoc-gen-go plugin
	GoGRPCEnabled          bool              // true to use protoc-gen-go-grpc
	GoPGVEnabled           bool              // enable protoc-gen-validate support
}

CompileParams are passed to Compile.

type StagedInputs

type StagedInputs struct {
	Paths        []string // absolute paths to search for protos
	InputDir     string   // absolute path to the directory with protos to compile
	OutputDir    string   // a directory with Go package root to put *.pb.go under
	ProtoFiles   []string // names of proto files in InputDir
	ProtoPackage string   // proto package path matching InputDir
	// contains filtered or unexported fields
}

StagedInputs represents a staging directory with Go modules symlinked into a way that `protoc` sees a consistent --proto_path.

func StageGenericInputs

func StageGenericInputs(ctx context.Context, inputDir string, protoImportPaths []string) (*StagedInputs, error)

StageGenericInputs just prepares StagedInputs from some generic directories on disk.

Unlike StageGoInputs it doesn't try to derive any information from what's there. Just converts paths to absolute and discovers *.proto files.

func StageGoInputs

func StageGoInputs(ctx context.Context, inputDir string, mods, rootMods, protoImportPaths []string) (inputs *StagedInputs, err error)

StageGoInputs stages a directory with Go Modules symlinked in appropriate places and prepares corresponding --proto_path paths.

If `inputDir` or any of given `protoImportPaths` are under any of the directories being staged, changes their paths to be rooted in the staged directory root. Such paths still point to the exact same directories, just through symlinks in the staging area.

func (*StagedInputs) Cleanup

func (s *StagedInputs) Cleanup() error

Cleanup removes the temporary staging directory.

Jump to

Keyboard shortcuts

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