Documentation ¶
Overview ¶
Packege environment implements setting up and handling environment variables.
Any varible implementing the Formatter interface can be set as value to Map.
Example usage:
envMap := environment.Map{ "OS": environemnt.String("linux"), "GOLANG": environment.True, "CORES": environment.Int(6), } env := envMap.IntoEnv() // converted to environment.Env the result is // env = {}string{"OS=linux", "GOLANG", "CORES=6"} // alternatively the Map above could be created like so: envMap := make(environment.Map) envMap.Set("OS", "linux") envMap.Use("GOLANG") envMap.SetInt("CORES", 6)
Index ¶
- Variables
- func BatchExecute(ctx context.Context, split SplitFn, ex Executor, opt Options, r io.Reader) error
- func Call(ctx context.Context, ex Executor, cmd string, args ...string) (s string, err error)
- func CallBackground(ex Executor, cmd string, args ...string) (s string, err error)
- func Run(ctx context.Context, ex Executor, cmd string, args ...string) error
- func RunBackground(ex Executor, cmd string, args ...string) error
- func SetString(s StringChecker, target *string, source string)
- type Builder
- type Debug
- type DryRunner
- type Env
- type EnvFormatter
- type Executor
- type ExecutorJSON
- type ExecutorKind
- type FilesCheck
- type Formatter
- type HasLength
- type Int
- type Into
- type IsValidPath
- type Lexer
- type LineFormatter
- type Map
- type MultiExecutor
- type MultiFormatter
- type NoOpExecute
- type Options
- type Setup
- type SharedEnv
- type Shlex
- type SplitFn
- type StdExecutor
- type String
- type StringChecker
- type Token
- type Tokenizer
- type ValidMismatch
- type Validator
- type ValidatorTester
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultOptions = Options{ Env: EmptyEnv, Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, }
View Source
var EmptyEnv = NewEnvironment(emptySlice)
EmptyEnv is an environment with no values.
View Source
var NonZeroLen = MinimumLength(1)
View Source
var OsFsValidator = fs.Validated(fs.OS(), fs.TypeEnsurer(path.TypeFile))
Functions ¶
func BatchExecute ¶
func CallBackground ¶
func SetString ¶
func SetString(s StringChecker, target *string, source string)
Types ¶
type Builder ¶
type Builder struct { Kind ExecutorKind Logging bool }
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a struct representing a set of environment values.
func NewEnvironment ¶
NewEnvironment creates an Env out of a string slice.
type EnvFormatter ¶
type EnvFormatter interface { // FormatEnv will return with the string representation of an environment // variable given a specific key. FormatEnv(key string) string }
Formatter is the value type for Map.
var True EnvFormatter = trueVal{}
True represents that the environment variable is set.
type ExecutorJSON ¶
type ExecutorJSON struct {
Executor
}
func (*ExecutorJSON) UnmarshalJSON ¶
func (e *ExecutorJSON) UnmarshalJSON(b []byte) (err error)
type FilesCheck ¶
type Formatter ¶
var LineFormat Formatter = (*LineFormatter)(nil)
type HasLength ¶
type HasLength struct {
// contains filtered or unexported fields
}
func MinimumLength ¶
func (HasLength) IsUpdateNeeded ¶
func (HasLength) StringUpdateNeeded ¶
type IsValidPath ¶
type IsValidPath bool
const ( PathValid IsValidPath = true PathNotValid IsValidPath = false )
func (IsValidPath) Match ¶
func (vp IsValidPath) Match(e error) (err error)
type MultiExecutor ¶
type MultiExecutor struct {
// contains filtered or unexported fields
}
type MultiFormatter ¶
type MultiFormatter struct {
// contains filtered or unexported fields
}
func (MultiFormatter) FormatCommand ¶
type Options ¶
type SharedEnv ¶
type SharedEnv struct {
// contains filtered or unexported fields
}
func SharedEnvExecutor ¶
type StringChecker ¶
type ValidMismatch ¶
type ValidMismatch struct { IsValidPath // contains filtered or unexported fields }
func (ValidMismatch) Error ¶
func (vm ValidMismatch) Error() (s string)
func (ValidMismatch) Unwrap ¶
func (vm ValidMismatch) Unwrap() (err error)
type ValidatorTester ¶
type ValidatorTester struct {
// contains filtered or unexported fields
}
func NewValidatorTester ¶
func NewValidatorTester(t *testing.T, val Validator) (vt ValidatorTester)
func (ValidatorTester) Expect ¶
func (vt ValidatorTester) Expect(like path.Like, v IsValidPath) (err error)
Click to show internal directories.
Click to hide internal directories.