cosmosbuf

package
v29.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidCommand indicates an invalid command name.
	ErrInvalidCommand = errors.New("invalid command name")

	// ErrProtoFilesNotFound indicates that no ".proto" files were found.
	ErrProtoFilesNotFound = errors.New("no proto files found")
)

Functions

func Version

func Version(ctx context.Context) (string, error)

Version runs the buf Version command.

Types

type Buf

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

Buf represents the buf application structure.

func New

func New(cacheStorage cache.Storage, goModPath string) (Buf, error)

New creates a new Buf based on the installed binary.

func (Buf) Export

func (b Buf) Export(ctx context.Context, protoDir, output string) error

Export runs the buf Export command for the files in the proto directory.

func (Buf) Format

func (b Buf) Format(ctx context.Context, path string) error

Format runs the buf Format command for the files in the provided path.

func (Buf) Generate

func (b Buf) Generate(
	ctx context.Context,
	protoPath,
	output,
	template string,
	options ...GenOption,
) (err error)

Generate runs the buf Generate command for each file into the proto directory.

func (Buf) Migrate

func (b Buf) Migrate(ctx context.Context, protoDir string) error

Migrate runs the buf Migrate command for the files in the app directory.

func (Buf) Update

func (b Buf) Update(ctx context.Context, modDir string) error

Update updates module dependencies. By default updates all dependencies unless one or more dependencies are specified.

type Command

type Command string

Command represents a high level command under buf.

const (

	// CMD*** are the buf commands.
	CMDBuf              = "buf"
	CMDGenerate Command = "generate"
	CMDExport   Command = "export"
	CMDFormat   Command = "format"
	CMDConfig   Command = "config"
	CMDDep      Command = "dep"
)

func (Command) String

func (c Command) String() string

String returns the command name.

type GenOption

type GenOption func(*genOptions)

GenOption configures code generation.

func ExcludeFiles

func ExcludeFiles(patterns ...string) GenOption

ExcludeFiles exclude file names from the generate command using glob.

func FileByFile

func FileByFile() GenOption

FileByFile runs the generate command for each proto file.

func IncludeImports

func IncludeImports() GenOption

IncludeImports also generate all imports except for Well-Known Types.

func IncludeWKT

func IncludeWKT() GenOption

IncludeWKT also generate Well-Known Types. Cannot be set without IncludeImports.

func WithFlag

func WithFlag(flag, value string) GenOption

WithFlag provides flag options for the buf generate command.

func WithModuleName added in v29.1.0

func WithModuleName(value string) GenOption

WithModuleName sets the module name to filter protos for.

Jump to

Keyboard shortcuts

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