Documentation
¶
Index ¶
- Constants
- func CustomParseCmdAndArgs(cmd *cobra.Command, args []string) *pflag.FlagSet
- func TmpFolderName(path string) string
- func WithArgs(args []string) gocOption
- func WithBuild() gocOption
- func WithDebug(enable bool) gocOption
- func WithExtra(extra string) gocOption
- func WithFlagSets(sets *pflag.FlagSet) gocOption
- func WithHost(host string) gocOption
- func WithInstall() gocOption
- func WithMode(mode string) gocOption
- type Build
- type FileVar
- type ModuleError
- type ModulePublic
- type Package
- type PackageCover
- type PackageError
Constants ¶
const ( GO_BUILD = iota GO_INSTALL )
Variables ¶
This section is empty.
Functions ¶
func CustomParseCmdAndArgs ¶
CustomParseCmdAndArgs 因为关闭了 cobra 的解析功能,需要手动构造并解析 goc flags
func TmpFolderName ¶
TmpFolderName generates a directory name according to the path
func WithFlagSets ¶
func WithInstall ¶
func WithInstall() gocOption
Types ¶
type Build ¶
type Build struct {
Args []string // all goc + go command line args + flags
FlagSets *pflag.FlagSet
BuildType int
Debug bool
Host string
Mode string // cover mode
Extra string
GOPATH string
GOBIN string
CurWd string
TmpWd string
CurModProjectDir string
TmpModProjectDir string
Goflags []string // go command line flags
GoArgs []string // go command line args
Packages []string // go command line [packages]
IsVendorMod bool // vendor, readonly, or mod?
IsModEdit bool // is mod file edited?
ImportPath string // the whole import path of the project
Pkgs map[string]*Package
GlobalCoverVarImportPath string
GlobalCoverVarImportPathDir string
}
Build struct a build
func NewInstall ¶
func NewInstall(opts ...gocOption) *Build
func (*Build) Build ¶
func (b *Build) Build()
Build starts go build
1. copy project to temp, 2. inject cover variables and functions into the project, 3. build the project in temp.
func (*Build) Inject ¶
func (b *Build) Inject()
Inject injects cover variables for all the .go files in the target directory
func (*Build) Install ¶
func (b *Build) Install()
Install starts go install
1. copy project to temp, 2. inject cover variables and functions into the project, 3. install the project in temp.
func (*Build) OnlyInject ¶
func (b *Build) OnlyInject()
type ModuleError ¶
type ModuleError struct {
Err string // error text
}
ModuleError represents the error loading module
type ModulePublic ¶
type ModulePublic struct {
Path string `json:",omitempty"` // module path
Version string `json:",omitempty"` // module version
Versions []string `json:",omitempty"` // available module versions
Replace *ModulePublic `json:",omitempty"` // replaced by this module
Time *time.Time `json:",omitempty"` // time version was created
Update *ModulePublic `json:",omitempty"` // available update (with -u)
Main bool `json:",omitempty"` // is this the main module?
Indirect bool `json:",omitempty"` // module is only indirectly needed by main module
Dir string `json:",omitempty"` // directory holding local copy of files, if any
GoMod string `json:",omitempty"` // path to go.mod file describing module, if any
GoVersion string `json:",omitempty"` // go version used in module
Error *ModuleError `json:",omitempty"` // error loading module
}
ModulePublic represents the package info of a module
type Package ¶
type Package struct {
Dir string `json:"Dir"` // directory containing package sources
ImportPath string `json:"ImportPath"` // import path of package in dir
Name string `json:"Name"` // package name
Target string `json:",omitempty"` // installed target for this package (may be executable)
Root string `json:",omitempty"` // Go root, Go path dir, or module root dir containing this package
Module *ModulePublic `json:",omitempty"` // info about package's module, if any
Goroot bool `json:"Goroot,omitempty"` // is this package in the Go root?
Standard bool `json:"Standard,omitempty"` // is this package part of the standard Go library?
DepOnly bool `json:"DepOnly,omitempty"` // package is only a dependency, not explicitly listed
// Source files
GoFiles []string `json:"GoFiles,omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
CgoFiles []string `json:"CgoFiles,omitempty"` // .go source files that import "C"
// Dependency information
Deps []string `json:"Deps,omitempty"` // all (recursively) imported dependencies
Imports []string `json:",omitempty"` // import paths used by this package
ImportMap map[string]string `json:",omitempty"` // map from source import to ImportPath (identity entries omitted)
// Error information
Incomplete bool `json:"Incomplete,omitempty"` // this package or a dependency has an error
Error *PackageError `json:"Error,omitempty"` // error loading package
DepsErrors []*PackageError `json:"DepsErrors,omitempty"` // errors loading dependencies
}
Package map a package output by go list this is subset of package struct in: https://github.com/golang/go/blob/master/src/cmd/go/internal/load/pkg.go#L58
type PackageCover ¶
PackageCover holds all the generate coverage variables of a package
type PackageError ¶
type PackageError struct {
ImportStack []string // shortest path from package named on command line to this one
Pos string // position of error (if present, file:line:col)
Err string // the error itself
}
PackageError is the error info for a package when list failed