Documentation ¶
Overview ¶
Package golang is an API to the Go compiler.
Index ¶
- type BuildOpts
- type Environ
- func (c *Environ) Apply(opts ...Opt)
- func (c Environ) Build(binaryPath string, pattern []string, opts *BuildOpts) error
- func (c Environ) BuildDir(dirPath string, binaryPath string, opts *BuildOpts) error
- func (c *Environ) Copy(opts ...Opt) *Environ
- func (c Environ) Env() []string
- func (c Environ) EnvHuman() []string
- func (c Environ) GoCmd(gocmd string, args ...string) *exec.Cmd
- func (c *Environ) Lookup(mode packages.LoadMode, patterns ...string) ([]*packages.Package, error)
- func (c *Environ) RegisterFlags(f *flag.FlagSet)
- func (c Environ) String() string
- func (c Environ) Valid() error
- func (c Environ) Version() (string, error)
- type ModBehavior
- type Opt
- func DisableCGO() Opt
- func WithBuildTag(tag ...string) Opt
- func WithGO111MODULE(go111module string) Opt
- func WithGOARCH(goarch string) Opt
- func WithGOOS(goos string) Opt
- func WithGOPATH(gopath string) Opt
- func WithGOROOT(goroot string) Opt
- func WithMod(mod ModBehavior) Opt
- func WithWorkingDir(wd string) Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildOpts ¶
type BuildOpts struct { // NoStrip builds an unstripped binary. // // Symbols and Build ID will be left in the binary. // // If NoTrimPath and NoStrip are false, the binary produced will be // reproducible. NoStrip bool // EnableInlining enables function inlining. EnableInlining bool // NoTrimPath produces a binary whose stack traces contain the module // root dirs, GOPATHs, and GOROOTs. // // If NoTrimPath and NoStrip are false, the binary produced will be // reproducible. NoTrimPath bool // ExtraArgs to `go build`. ExtraArgs []string }
Optional arguments to Environ.BuildDir.
func (*BuildOpts) RegisterFlags ¶
RegisterFlags registers flags for BuildOpts.
type Environ ¶
type Environ struct { build.Context GO111MODULE string Mod ModBehavior GBBDEBUG bool }
Environ are the environment variables for the Go compiler.
func Default ¶
Default is the default build environment comprised of the default GOPATH, GOROOT, GOOS, GOARCH, and CGO_ENABLED values.
func (Environ) BuildDir ¶
BuildDir compiles the package in the directory `dirPath`, writing the build object to `binaryPath`.
func (*Environ) Lookup ¶
Lookup looks up packages by patterns relative to dir, using the Go environment from c.
func (*Environ) RegisterFlags ¶
RegisterFlags registers flags for Environ.
type ModBehavior ¶
type ModBehavior string
const ( ModNone ModBehavior = "" ModOnly ModBehavior = "mod" ModReadonly ModBehavior = "readonly" ModVendor ModBehavior = "vendor" )
type Opt ¶
type Opt func(*Environ)
Opt is an option function applied to Environ.
func WithBuildTag ¶
WithBuildTag is an option that appends build tags.
func WithGO111MODULE ¶
WithGO111MODULE is an option that overrides GO111MODULE.
func WithMod ¶
func WithMod(mod ModBehavior) Opt
WithMod is an option that overrides module behavior.
func WithWorkingDir ¶
WithWorkingDir sets the working directory for calls to `go`.