env

package
v0.0.0-...-b7787a3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

package env implements functions that make assertions on the state of the local execution environment.

Index

Constants

This section is empty.

Variables

FS uses the local machine's filesystem

Functions

func Executable

func Executable(program string) (string, error)

Executable asserts that program is present and executable on the local system. Returns the resolved path to the program.

func ExpandPkg

func ExpandPkg(pkg string) (string, error)

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

func IsPkgNotFound(err error) bool

IsPkgNotFound returns true if err's cause is of type PkgNotFoundError

func NpmPkgExists

func NpmPkgExists(pkg string) (string, error)

NpmPkgExists ensures an npm package is installed globally. TODO: make testable.

func PkgExists

func PkgExists(pkg string) (string, error)

PkgExists returns the absolute path of pkg and ensures that the package is present on the local file system underneath GOPATH.

func PkgPath

func PkgPath(pkg string) (string, error)

PkgPath returns the absolute path of pkg and ensures that the package is present on the local file system underneath GOPATH.

func RealPath

func RealPath(path string) (string, error)

RealPath resolves path against the current FS implementation, returning the actual local filesystem path if possible. Useful for calling out to external commands that requires paths while still being able to override FS in tests.

func Version

func Version() string

Version returns the version string that was included when building the current program, or "devel" should one not be set.

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 DefaultBackend Backend = OS
var OS Backend = &osBackend{}

OS represents a backend that uses the real os

type NotOnGoPathError

type NotOnGoPathError struct {
	Path   string
	GoPath []string
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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