rungo

package module
v0.0.0-...-c34b80d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultGoExecutablePath = "go"

DefaultGoExecutablePath is the default path of `go` executable.

Variables

View Source
var ErrUnexpectCommandOutput = errors.New("output of `go` command not in expected form")

ErrUnexpectCommandOutput indicate the output of `go` command not in expected form. The content parsing is failed.

Functions

This section is empty.

Types

type CommandGo

type CommandGo struct {
	ExecutablePath string
}

CommandGo wraps command invocation and result parsing of `go` command.

func (*CommandGo) Env

func (c *CommandGo) Env() (result *EnvInfo, err error)

Env get environment information with `go env -json`.

func (*CommandGo) ListModule

func (c *CommandGo) ListModule(pkgImportPath ...string) (result []*Module, err error)

ListModule get module information with `go list -json -m`.

func (*CommandGo) ListPackage

func (c *CommandGo) ListPackage(pkgImportPath ...string) (result []*Package, err error)

ListPackage get package information with `go list -json`.

func (*CommandGo) ModuleDownload

func (c *CommandGo) ModuleDownload(modulePathPatterns ...string) (result []*ModuleDownloadResult, err error)

ModuleDownload downloads the named modules with `go mod download -json -m`.

func (*CommandGo) Version

func (c *CommandGo) Version() (majorVer, minorVer int, outputText string, err error)

Version wrap `go version` command.

type EnvInfo

type EnvInfo struct {
	Arch       string `json:"GOARCH"`
	Bin        string `json:"GOBIN"`
	Cache      string `json:"GOCACHE"`
	EnvFile    string `json:"GOENV"`
	ExeSuffix  string `json:"GOEXE"`
	Flags      string `json:"GOFLAGS"`
	HostArch   string `json:"GOHOSTARCH"`
	HostOS     string `json:"GOHOSTOS"`
	GoNoProxy  string `json:"GONOPROXY"`
	GoNoSumDB  string `json:"GONOSUMDB"`
	OS         string `json:"GOOS"`
	GoPath     string `json:"GOPATH"`
	GoPrivate  string `json:"GOPRIVATE"`
	GoProxy    string `json:"GOPROXY"`
	GoRoot     string `json:"GOROOT"`
	GoSumDB    string `json:"GOSUMDB"`
	TmpDir     string `json:"GOTMPDIR"`
	ToolDir    string `json:"GOTOOLDIR"`
	GCCGO      string `json:"GCCGO"`
	AR         string `json:"AR"`
	CC         string `json:"CC"`
	CXX        string `json:"CXX"`
	CGOENABLED string `json:"CGO_ENABLED"`
}

EnvInfo represent the result of `go env` command. JSON key came from: https://golang.org/src/cmd/go/internal/envcmd/env.go

type Module

type Module struct {
	Path      string       `json:",omitempty"` // module path
	Version   string       `json:",omitempty"` // module version
	Versions  []string     `json:",omitempty"` // available module versions
	Replace   *Module      `json:",omitempty"` // replaced by this module
	Time      *time.Time   `json:",omitempty"` // time version was created
	Update    *Module      `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
}

Module is the structure of Module structure in `go list -json` result.

func (*Module) String

func (m *Module) String() string

type ModuleDownloadResult

type ModuleDownloadResult struct {
	Path     string `json:",omitempty"` // module path
	Version  string `json:",omitempty"` // module version
	Error    string `json:",omitempty"` // error loading module
	Info     string `json:",omitempty"` // absolute path to cached .info file
	GoMod    string `json:",omitempty"` // absolute path to cached .mod file
	Zip      string `json:",omitempty"` // absolute path to cached .zip file
	Dir      string `json:",omitempty"` // absolute path to cached source root directory
	Sum      string `json:",omitempty"` // checksum for path, version (as in go.sum)
	GoModSum string `json:",omitempty"` // checksum for go.mod (as in go.sum)
	Latest   bool   // would @latest resolve to this version?
}

ModuleDownloadResult is the structure of module download description structure in `go mod download -json` result.

type ModuleError

type ModuleError struct {
	Err string // error text
}

ModuleError is the loading module error.

type Package

type Package struct {
	// Note: These fields are part of the go command's public API.
	// See list.go. It is okay to add fields, but not to change or
	// remove existing ones. Keep in sync with list.go
	Dir           string   `json:",omitempty"` // directory containing package sources
	ImportPath    string   `json:",omitempty"` // import path of package in dir
	ImportComment string   `json:",omitempty"` // path in import comment on package statement
	Name          string   `json:",omitempty"` // package name
	Doc           string   `json:",omitempty"` // package documentation string
	Target        string   `json:",omitempty"` // installed target for this package (may be executable)
	Shlib         string   `json:",omitempty"` // the shared library that contains this package (only set when -linkshared)
	Root          string   `json:",omitempty"` // Go root, Go path dir, or module root dir containing this package
	ConflictDir   string   `json:",omitempty"` // Dir is hidden by this other directory
	ForTest       string   `json:",omitempty"` // package is only for use in named test
	Export        string   `json:",omitempty"` // file containing export data (set by go list -export)
	Module        *Module  `json:",omitempty"` // info about package's module, if any
	Match         []string `json:",omitempty"` // command-line patterns matching this package
	Goroot        bool     `json:",omitempty"` // is this package found in the Go root?
	Standard      bool     `json:",omitempty"` // is this package part of the standard Go library?
	DepOnly       bool     `json:",omitempty"` // package is only as a dependency, not explicitly listed
	BinaryOnly    bool     `json:",omitempty"` // package cannot be recompiled
	Incomplete    bool     `json:",omitempty"` // was there an error loading this package or dependencies?

	// Stale and StaleReason remain here *only* for the list command.
	// They are only initialized in preparation for list execution.
	// The regular build determines staleness on the fly during action execution.
	Stale       bool   `json:",omitempty"` // would 'go install' do anything for this package?
	StaleReason string `json:",omitempty"` // why is Stale true?

	// Source files
	// If you add to this list you MUST add to p.AllFiles (below) too.
	// Otherwise file name security lists will not apply to any new additions.
	GoFiles         []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
	CgoFiles        []string `json:",omitempty"` // .go source files that import "C"
	CompiledGoFiles []string `json:",omitempty"` // .go output from running cgo on CgoFiles
	IgnoredGoFiles  []string `json:",omitempty"` // .go source files ignored due to build constraints
	CFiles          []string `json:",omitempty"` // .c source files
	CXXFiles        []string `json:",omitempty"` // .cc, .cpp and .cxx source files
	MFiles          []string `json:",omitempty"` // .m source files
	HFiles          []string `json:",omitempty"` // .h, .hh, .hpp and .hxx source files
	FFiles          []string `json:",omitempty"` // .f, .F, .for and .f90 Fortran source files
	SFiles          []string `json:",omitempty"` // .s source files
	SwigFiles       []string `json:",omitempty"` // .swig files
	SwigCXXFiles    []string `json:",omitempty"` // .swigcxx files
	SysoFiles       []string `json:",omitempty"` // .syso system object files added to package

	// Cgo directives
	CgoCFLAGS    []string `json:",omitempty"` // cgo: flags for C compiler
	CgoCPPFLAGS  []string `json:",omitempty"` // cgo: flags for C preprocessor
	CgoCXXFLAGS  []string `json:",omitempty"` // cgo: flags for C++ compiler
	CgoFFLAGS    []string `json:",omitempty"` // cgo: flags for Fortran compiler
	CgoLDFLAGS   []string `json:",omitempty"` // cgo: flags for linker
	CgoPkgConfig []string `json:",omitempty"` // cgo: pkg-config names

	// Dependency information
	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)
	Deps      []string          `json:",omitempty"` // all (recursively) imported dependencies

	// Error information
	// Incomplete is above, packed into the other bools
	Error      *PackageError   `json:",omitempty"` // error loading this package (not dependencies)
	DepsErrors []*PackageError `json:",omitempty"` // errors loading dependencies

	// Test information
	// If you add to this list you MUST add to p.AllFiles (below) too.
	// Otherwise file name security lists will not apply to any new additions.
	TestGoFiles  []string `json:",omitempty"` // _test.go files in package
	TestImports  []string `json:",omitempty"` // imports from TestGoFiles
	XTestGoFiles []string `json:",omitempty"` // _test.go files outside package
	XTestImports []string `json:",omitempty"` // imports from XTestGoFiles
}

Package is the structure of Package structure in `go list -json` result.

type PackageError

type PackageError struct {
	ImportStack []string // shortest path from package named on command line to this one
	Pos         string   // position of error
	Err         string   // the error itself
}

PackageError describes an error loading information about a package.

func (*PackageError) Error

func (p *PackageError) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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