v0.10.0 Latest Latest

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

Go to latest
Published: Oct 10, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0



Package golang is an API to the Go compiler.



This section is empty.


This section is empty.


This section is empty.


type BuildOpts

type BuildOpts struct {
	// NoStrip builds an unstripped binary.
	NoStrip bool
	// ExtraArgs to `go build`.
	ExtraArgs []string

Optional arguments to Environ.Build.

type Environ

type Environ struct {

func Default

func Default() Environ

Default is the default build environment comprised of the default GOPATH, GOROOT, GOOS, GOARCH, and CGO_ENABLED values.

func (Environ) Build

func (c Environ) Build(importPath string, binaryPath string, opts BuildOpts) error

Build compiles the package given by `importPath`, writing the build object to `binaryPath`.

func (Environ) BuildDir

func (c Environ) BuildDir(dirPath string, binaryPath string, opts BuildOpts) error

BuildDir compiles the package in the directory `dirPath`, writing the build object to `binaryPath`.

func (Environ) Deps

func (c Environ) Deps(importPath string) (*ListPackage, error)

Deps lists all dependencies of the package given by `importPath`.

func (Environ) Env

func (c Environ) Env() []string

func (Environ) GoCmd

func (c Environ) GoCmd(args ...string) *exec.Cmd

GoCmd runs a go command in the environment.

func (Environ) Package

func (c Environ) Package(importPath string) (*build.Package, error)

Package retrieves information about a package by its Go import path.

func (Environ) PackageByPath

func (c Environ) PackageByPath(path string) (*build.Package, error)

PackageByPath retrieves information about a package by its file system path.

`path` is assumed to be the directory containing the package.

func (Environ) String

func (c Environ) String() string

func (Environ) Version

func (c Environ) Version() (string, error)

Version returns the Go version string that runtime.Version would return for the Go compiler in this environ.

type ListPackage

type ListPackage struct {
	Dir        string
	Deps       []string
	GoFiles    []string
	SFiles     []string
	HFiles     []string
	Goroot     bool
	Root       string
	ImportPath string

ListPackage matches a subset of the JSON output of the `go list -json` command.

See `go help list` for the full structure.

This currently contains an incomplete list of dependencies.

Jump to

Keyboard shortcuts

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