generate

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package generate runs `buf generate` against a prepared workspace, either in a Docker container (default) or with a host buf binary. A single backend is reused across all language jobs so per-language toolchain setup happens once.

Index

Constants

View Source
const (
	RunnerAuto   = "auto"
	RunnerDocker = "docker"
	RunnerHost   = "host"
)

Runner selection values for Options.Runner.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator interface {
	Generate(ctx context.Context, workspaceDir, outDir string, jobs []*Job) error
}

Generator runs buf for a set of jobs against a prepared workspace, writing generated code into outDir.

func New

func New(opts *Options, log *slog.Logger) (Generator, error)

New selects a generator per opts.Runner. "auto" prefers a host buf binary and falls back to Docker.

type Job

type Job struct {
	Lang         string // "go" | "js"
	TemplateFile string // buf gen template file name, relative to the workspace root
}

Job is a single language generation: which template within the workspace to run buf with.

type Options

type Options struct {
	Runner    string // auto | docker | host
	Image     string // Docker image, default "bufbuild/buf"
	Tag       string // Docker image tag, default "1.54.0"
	MemoryGiB int    // container memory limit in GiB, default 2
}

Options configures the generator. Zero values are replaced by defaults.

Jump to

Keyboard shortcuts

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