buildutils

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultBuilder is the default Builder.
	DefaultBuilder = Builder{}

	// Build is an alias for DefaultBuilder.Build.
	Build = DefaultBuilder.Build
)
View Source
var ForceRebuild = forceRebuild{}

ForceRebuild is an option to force rebuilding packages.

Functions

This section is empty.

Types

type BuildOption

type BuildOption interface {
	// ApplyToBuild applies the option to the BuildOptions.
	ApplyToBuild(o *BuildOptions)
}

BuildOption are options to apply to BuildOptions.

type BuildOptions

type BuildOptions struct {
	// ForceRebuild forces rebuilding of packages that are already up-to-date.
	ForceRebuild bool
	// Mod specifies the module download mode to use.
	Mod *ModMode
}

BuildOptions are options to supply for a Build.

func (*BuildOptions) ApplyOptions

func (o *BuildOptions) ApplyOptions(opts []BuildOption)

ApplyOptions applies the slice of BuildOption to this BuildOptions.

func (*BuildOptions) ApplyToBuild

func (o *BuildOptions) ApplyToBuild(o2 *BuildOptions)

ApplyToBuild implements BuildOption.

type Builder

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

Builder is a builder for go code.

func NewBuilder

func NewBuilder(opts BuilderOptions) *Builder

NewBuilder creates a new Builder with the given options.

func (*Builder) Build

func (b *Builder) Build(name, filename string, opts ...BuildOption) error

Build runs `go build` with the target output and name. If BuilderOptions.Tidy was set, it runs `go mod tidy` beforehand.

type BuilderOptions

type BuilderOptions struct {
	// Dir is the working directory for the Builder.
	Dir string
	// Tidy can specify whether the builder should run `go mod tidy` before building.
	Tidy bool
}

BuilderOptions are options to create a builder with.

type ModMode

type ModMode string

ModMode is the module download mode to use.

const (
	// ModModeVendor causes modules to be resolved from a vendor folder.
	ModModeVendor ModMode = "vendor"
	// ModModeReadonly expect all modules to be present in the module cache for the current module.
	ModModeReadonly ModMode = "readonly"
	// ModModeMod fetches any module before building.
	ModModeMod ModMode = "mod"
)

func (ModMode) ApplyToBuild

func (m ModMode) ApplyToBuild(o *BuildOptions)

ApplyToBuild implements BuildOption.

Jump to

Keyboard shortcuts

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