build

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrShouldNotReached represents the logic should not be reached in normal flow
	ErrShouldNotReached = errors.New("should never be reached")
	// ErrGocShouldExecInProject represents goc currently not support for the project
	ErrGocShouldExecInProject = errors.New("goc not support for such project directory")
	// ErrWrongPackageTypeForInstall represents goc install command only support limited arguments
	ErrWrongPackageTypeForInstall = errors.New("packages only support \".\" and \"./...\"")
	// ErrWrongPackageTypeForBuild represents goc build command only support limited arguments
	ErrWrongPackageTypeForBuild = errors.New("packages only support \".\"")
	// ErrTooManyArgs represents goc CLI only support limited arguments
	ErrTooManyArgs = errors.New("too many args")
	// ErrInvalidWorkingDir represents the working directory is invalid
	ErrInvalidWorkingDir = errors.New("the working directory is invalid")
	// ErrEmptyTempWorkingDir represent the error that temporary working directory is empty
	ErrEmptyTempWorkingDir = errors.New("temporary working directory is empty")
	// ErrNoPlaceToInstall represents the err that no place to install the generated binary
	ErrNoPlaceToInstall = errors.New("don't know where to install")
)

Functions

This section is empty.

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
	ModRoot     string // path for go.mod
	ModRootPath string // import path for the whole project
	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

	OneMainPackage           bool   // whether this build is a go build or go install? true: build, false: install
	GlobalCoverVarImportPath string // Importpath for storing cover variables
	GlobalCoverVarFilePath   string // Importpath for storing cover variables
}

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

Build calls 'go build' tool to do building

func (*Build) Clean

func (b *Build) Clean() error

Clean clears up the temporary workspace

func (*Build) Install

func (b *Build) Install() error

Install use the 'go install' tool to install packages

func (*Build) MvProjectsToTmp

func (b *Build) MvProjectsToTmp() error

MvProjectsToTmp moves the projects into a temporary directory

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