build

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShouldNotReached           = errors.New("should never be reached")
	ErrGocShouldExecInProject     = errors.New("goc not executed in project directory")
	ErrWrongPackageTypeForInstall = errors.New("packages only support \".\" and \"./...\"")
	ErrWrongPackageTypeForBuild   = errors.New("packages only support \".\"")
	ErrTooManyArgs                = errors.New("too many args")
	ErrInvalidWorkingDir          = errors.New("the working directory is invalid")
	ErrWrongCallSequence          = errors.New("function should be called in a specified sequence")
	ErrNoplaceToInstall           = errors.New("dont know where to install")
)

Functions

func TmpFolderName

func TmpFolderName(path string) string

Types

type Build

type Build struct {
	Pkgs          map[string]*cover.Package // Pkg list parsed from "go list -json ./..." command
	NewGOPATH     string                    // the new GOPATH
	OriGOPATH     string                    // the original GOPATH
	WorkingDir    string                    // the working directory
	TmpDir        string                    // the temporary directory to build the project
	TmpWorkingDir string                    // the working directory in the temporary directory, which is corresponding to the current directory in the project directory
	IsMod         bool                      // determine whether it is a Mod project
	Root          string
	// go 1.11, go 1.12 has no Root
	// Project Root:
	// 1. legacy, root == GOPATH
	// 2. mod, root == go.mod Dir
	Target string // the binary name that go build generate
	// keep compatible with go commands:
	// go run [build flags] [-exec xprog] package [arguments...]
	// go build [-o output] [-i] [build flags] [packages]
	// go install [-i] [build flags] [packages]
	BuildFlags     string // Build flags
	Packages       string // Packages that needs to build
	GoRunExecFlag  string // for the -exec flags in go run command
	GoRunArguments string // for the '[arguments]' parameters in go run command
}

Build is to describe the building/installing process of a goc build/install

func NewBuild

func NewBuild(buildflags string, args []string, workingDir string, outputDir string) (*Build, error)

NewBuild creates a Build struct which can build from goc temporary directory, and generate binary in current working directory

func NewInstall

func NewInstall(buildflags string, args []string, workingDir string) (*Build, error)

NewInstall creates a Build struct which can install from goc temporary directory

func (*Build) Build

func (b *Build) Build() error

func (*Build) Clean

func (b *Build) Clean() error

Clean clears up the temporary workspace

func (*Build) Install

func (b *Build) Install() error

func (*Build) MvProjectsToTmp

func (b *Build) MvProjectsToTmp() error

func (*Build) Run

func (b *Build) Run() error

Run excutes the main package in addition with the internal goc features

Jump to

Keyboard shortcuts

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