Help us shape the future of Go! Take the 2026 Go Developer Survey

build

package
v2.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 30 Imported by: 6

Documentation

Index

Constants

View Source
const (
	VERBOSE int = 2
)

Variables

This section is empty.

Functions

func Build

func Build(options *Options) (string, error)

Build the project!

func CreateEmbedDirectories added in v2.1.0

func CreateEmbedDirectories(cwd string, buildOptions *Options) error

func GenerateBindings

func GenerateBindings(buildOptions *Options) error

func GenerateNSISInstaller

func GenerateNSISInstaller(options *Options, amd64Binary string, arm64Binary string) error

func SyncFrontendDistToEmbedTarget added in v2.13.0

func SyncFrontendDistToEmbedTarget(options *Options) (func(), error)

SyncFrontendDistToEmbedTarget copies the built frontend assets from the custom frontend:dir/dist into the embed target directory (usually frontend/dist) so the //go:embed directive finds them. It returns a cleanup function that restores the embed target to just a .gitkeep placeholder after the build, keeping the working tree clean. The cleanup runs even on error.

Types

type BaseBuilder

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

BaseBuilder is the common builder struct

func NewBaseBuilder

func NewBaseBuilder(options *Options) *BaseBuilder

NewBaseBuilder creates a new BaseBuilder

func (*BaseBuilder) BuildFrontend

func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error

BuildFrontend executes the `npm build` command for the frontend directory

func (*BaseBuilder) CleanUp

func (b *BaseBuilder) CleanUp()

CleanUp does post-build housekeeping

func (*BaseBuilder) CompileProject

func (b *BaseBuilder) CompileProject(options *Options) error

CompileProject compiles the project

func (*BaseBuilder) NpmInstall

func (b *BaseBuilder) NpmInstall(sourceDir string, verbose bool) error

NpmInstall runs "npm install" in the given directory

func (*BaseBuilder) NpmInstallUsingCommand

func (b *BaseBuilder) NpmInstallUsingCommand(sourceDir string, installCommand string, verbose bool) error

NpmInstallUsingCommand runs the given install command in the specified npm project directory

func (*BaseBuilder) NpmRun

func (b *BaseBuilder) NpmRun(projectDir, buildTarget string, verbose bool) error

NpmRun executes the npm target in the provided directory

func (*BaseBuilder) NpmRunWithEnvironment

func (b *BaseBuilder) NpmRunWithEnvironment(projectDir, buildTarget string, verbose bool, envvars []string) error

NpmRunWithEnvironment executes the npm target in the provided directory, with the given environment variables

func (*BaseBuilder) OutputFilename

func (b *BaseBuilder) OutputFilename(options *Options) string

func (*BaseBuilder) SetProjectData

func (b *BaseBuilder) SetProjectData(projectData *project.Project)

SetProjectData sets the project data for this builder

type Builder

type Builder interface {
	SetProjectData(projectData *project.Project)
	BuildFrontend(logger *clilogger.CLILogger) error
	CompileProject(options *Options) error
	OutputFilename(options *Options) string
	CleanUp()
}

Builder defines a builder that can build Wails applications

type DesktopBuilder

type DesktopBuilder struct {
	*BaseBuilder
}

DesktopBuilder builds applications for the desktop

type Mode

type Mode int

Mode is the type used to indicate the build modes

const (
	// Dev mode
	Dev Mode = iota
	// Production mode
	Production
	// Debug build
	Debug
)

type Options

type Options struct {
	LDFlags           string               // Optional flags to pass to linker
	UserTags          []string             // Tags to pass to the Go compiler
	Logger            *clilogger.CLILogger // All output to the logger
	OutputType        string               // EG: desktop, server....
	Mode              Mode                 // release or dev
	Devtools          bool                 // Enable devtools in production
	ProjectData       *project.Project     // The project data
	Pack              bool                 // Create a package for the app after building
	Platform          string               // The platform to build for
	Arch              string               // The architecture to build for
	Compiler          string               // The compiler command to use
	SkipModTidy       bool                 //  Skip mod tidy before compile
	IgnoreFrontend    bool                 // Indicates if the frontend does not need building
	IgnoreApplication bool                 // Indicates if the application does not need building
	InstallScope      string               // "machine" (default) or "user"
	OutputFile        string               // Override the output filename
	BinDirectory      string               // Directory to use to write the built applications
	CleanBinDirectory bool                 // Indicates if the bin output directory should be cleaned before building
	CompiledBinary    string               // Fully qualified path to the compiled binary
	KeepAssets        bool                 // Keep the generated assets/files
	Verbosity         int                  // Verbosity level (0 - silent, 1 - default, 2 - verbose)
	Compress          bool                 // Compress the final binary
	CompressFlags     string               // Flags to pass to UPX
	WebView2Strategy  string               // WebView2 installer strategy
	RunDelve          bool                 // Indicates if we should run delve after the build
	WailsJSDir        string               // Directory to generate the wailsjs module
	ForceBuild        bool                 // Force
	BundleName        string               // Bundlename for Mac
	TrimPath          bool                 // Use Go's trimpath compiler flag
	RaceDetector      bool                 // Build with Go's race detector
	WindowsConsole    bool                 // Indicates that the windows console should be kept
	Obfuscated        bool                 // Indicates that bound methods should be obfuscated
	GarbleArgs        string               // The arguments for Garble
	SkipBindings      bool                 // Skip binding generation
	SkipEmbedCreate   bool                 // Skip creation of embed files
}

Options contains all the build options as well as the project data

Jump to

Keyboard shortcuts

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