protoc

package
v28.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package protoc provides high level access to protoc command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, outDir, protoPath string, includePaths, protocOuts []string, options ...Option) error

Generate generates code into outDir from protoPath and its includePaths by using plugins provided with protocOuts.

Types

type Cmd

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

Cmd contains the information necessary to execute the protoc command.

func Command

func Command() (command Cmd, cleanup func(), err error)

Command sets the protoc binary up and returns the command needed to execute c.

func (Cmd) Command

func (c Cmd) Command() []string

Command returns the strings to execute the `protoc` command.

func (Cmd) Includes

func (c Cmd) Includes() []string

Includes returns the proto files import paths.

type Option

type Option func(*configs)

Option configures Generate configs.

func Env

func Env(v ...string) Option

Env assigns environment values during the code generation.

func GenerateDependencies

func GenerateDependencies() Option

GenerateDependencies enables code generation for the proto files that your protofile depends on. use this if your protoc plugin does not give you an option to enable the same feature.

func Plugin

func Plugin(path string, options ...string) Option

Plugin configures a plugin for code generation.

func WithCommand

func WithCommand(command Cmd) Option

WithCommand assigns a protoc command to use for code generation. This allows to use a single protoc binary in multiple code generation calls. Otherwise, `Generate` creates a new protoc binary each time it is called.

Jump to

Keyboard shortcuts

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