goenv

package
v0.0.0-...-fe628ba Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GOPATH

func GOPATH() (string, error)

GOPATH returns GOPATH reading from environment variables. If GOPATH is missing it returns $HOME/go.

func PkgPath

func PkgPath(subDir, pkg string) string

PkgPath returns the file path of a sub directory (e.g. src, bin, etc.) for a particular package.

func SrcDir

func SrcDir(pkg string) string

SrcDir returns the Go language source directory.

func SrcFile

func SrcFile(f string) string

SrcFile returns the file path of a Go language source file.

Types

type ExecEnv

type ExecEnv struct {
	// contains filtered or unexported fields
}

ExecEnv is an execution environment for executing a Go language related command.

func NewExecEnv

func NewExecEnv(gopath string) *ExecEnv

NewExecEnv creates a new execution environment for a particular GOPATH.

func (*ExecEnv) BindPipe

func (env *ExecEnv) BindPipe(w io.Writer)

BindPipe will forward stdout and stderr to the given writer, rather than os.Stdout and os.Stderr.

func (*ExecEnv) Call

func (env *ExecEnv) Call(dir, name string, args ...string) (bool, error)

Call executes a process in the environment and returns true if the process ends and exits with a success exit code, false if the process ends and exists with a non-success exit code.

func (*ExecEnv) Cmd

func (env *ExecEnv) Cmd(j *ExecJob) *exec.Cmd

Cmd creates an execution process using a given execution job.

func (*ExecEnv) Context

func (env *ExecEnv) Context() *build.Context

Context returns the build context that is used by this environment.

func (*ExecEnv) Exec

func (env *ExecEnv) Exec(dir, name string, args ...string) error

Exec executes a process in the environment.

func (*ExecEnv) GOPATH

func (env *ExecEnv) GOPATH() string

GOPATH returns the GOPATH for this environment.

func (*ExecEnv) IsDir

func (env *ExecEnv) IsDir(p string) (bool, error)

IsDir checks if p exists as a directory under the GOPATH.

func (*ExecEnv) PipedCmd

func (env *ExecEnv) PipedCmd(j *ExecJob) *exec.Cmd

PipedCmd creates an execution process using a given execution job similar to Cmd but also forward through the Stdout and Stderr.

func (*ExecEnv) StrOut

func (env *ExecEnv) StrOut(dir, name string, args ...string) (string, error)

StrOut executes a process in the environment and returns the output as a string.

type ExecJob

type ExecJob struct {
	Dir  string
	Name string
	Args []string
}

ExecJob is an execution job to be executed in an execution environment.

Jump to

Keyboard shortcuts

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