gobuild

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const InstallMethod = "go-build"

Variables

This section is empty.

Functions

func DefaultVersionResolverConfig

func DefaultVersionResolverConfig(installParams any) (string, any, error)

DefaultVersionResolverConfig returns the default version resolver configuration for the given install parameters. For local modules, it uses the git resolver. For GitHub modules, it uses the github-release resolver. For other modules, it falls back to the goproxy resolver.

func DeriveGitHubRepo

func DeriveGitHubRepo(module string) string

DeriveGitHubRepo extracts the owner/repo portion from a GitHub module path. Returns empty string for non-GitHub modules.

func DeriveRepoURL

func DeriveRepoURL(module string) (string, error)

DeriveRepoURL derives the git repository URL from a Go module path. For GitHub modules, it constructs the HTTPS URL. For other hosts, it returns an error asking for an explicit repo-url.

func IsInstallMethod

func IsInstallMethod(method string) bool

IsInstallMethod returns true if the given method string refers to the go-build installer.

func IsLocalModule

func IsLocalModule(module string) bool

IsLocalModule returns true if the module path refers to a local filesystem path.

Types

type Installer

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

Installer builds Go binaries from source code obtained via git or go proxy.

func NewInstaller

func NewInstaller(cfg InstallerParameters) Installer

NewInstaller creates a new go-build installer with the given configuration.

func (Installer) InstallTo

func (i Installer) InstallTo(ctx context.Context, version, destDir string) (string, error)

InstallTo builds the Go module and places the resulting binary in destDir.

type InstallerParameters

type InstallerParameters struct {
	Module     string     `json:"module" yaml:"module" mapstructure:"module"`
	Entrypoint string     `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty" mapstructure:"entrypoint"`
	LDFlags    []string   `json:"ldflags,omitempty" yaml:"ldflags,omitempty" mapstructure:"ldflags"`
	Args       []string   `json:"args,omitempty" yaml:"args,omitempty" mapstructure:"args"`
	Env        []string   `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env"`
	Source     SourceMode `json:"source,omitempty" yaml:"source,omitempty" mapstructure:"source"`
	RepoURL    string     `json:"repo-url,omitempty" yaml:"repo-url,omitempty" mapstructure:"repo-url"`
}

InstallerParameters contains the configuration for building a Go module from source.

type SourceMode

type SourceMode string

SourceMode indicates how to obtain the source code for building.

const (
	// SourceModeGit clones the repository using git.
	SourceModeGit SourceMode = "git"
	// SourceModeGoProxy downloads source via the go proxy.
	SourceModeGoProxy SourceMode = "go-proxy"
)

Jump to

Keyboard shortcuts

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