Documentation
¶
Overview ¶
package env implements functions that make assertions on the state of the local execution environment.
Index ¶
- Variables
- func Executable(program string) (string, error)
- func ExpandPkg(pkg string) (string, error)
- func IsPkgNotFound(err error) bool
- func NpmPkgExists(pkg string) (string, error)
- func PkgExists(pkg string) (string, error)
- func PkgPath(pkg string) (string, error)
- func RealPath(path string) (string, error)
- func Version() string
- type Backend
- type NotOnGoPathError
- type PkgNotFoundError
Constants ¶
This section is empty.
Variables ¶
var FS = afero.NewOsFs()
FS uses the local machine's filesystem
Functions ¶
func Executable ¶
Executable asserts that program is present and executable on the local system. Returns the resolved path to the program.
func ExpandPkg ¶
ExpandPkg takes a package spec that may be relative to the local directory and returns the full package name. Errors if the expanded path is not underneath an element of the current GOPATH.
func IsPkgNotFound ¶
IsPkgNotFound returns true if err's cause is of type PkgNotFoundError
func NpmPkgExists ¶
NpmPkgExists ensures an npm package is installed globally. TODO: make testable.
func PkgExists ¶
PkgExists returns the absolute path of pkg and ensures that the package is present on the local file system underneath GOPATH.
func PkgPath ¶
PkgPath returns the absolute path of pkg and ensures that the package is present on the local file system underneath GOPATH.
Types ¶
type Backend ¶
type Backend interface { Getwd() (string, error) Getenv(string) string // LookupPath searches the local environment for program, returning the // absolute path for the program. LookupPath(program string) (string, error) }
Backend is a backend
var OS Backend = &osBackend{}
OS represents a backend that uses the real os
type NotOnGoPathError ¶
func (*NotOnGoPathError) Error ¶
func (err *NotOnGoPathError) Error() string
type PkgNotFoundError ¶
type PkgNotFoundError struct {
Pkg string
}
PkgNotFoundError is the error returns when a package cannot be found in the GOPATH.
func (*PkgNotFoundError) Error ¶
func (err *PkgNotFoundError) Error() string