Documentation
¶
Index ¶
- func Expand(s string, mapping func(string) string) string
- func ExpandNoEscape(s string, mapping func(string) string) string
- func Mapping(env, home string, p platform.Platform) func(s string) string
- func MarshalOps(ops Ops) ([]byte, error)
- type Append
- type Envars
- type Force
- type Op
- type Ops
- type Prefix
- type Prepend
- type Set
- type Transform
- type Unset
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expand ¶ added in v0.44.9
Expand repeatedly expands s until the mapping function stops making substitutions. This is useful for variables that reference other variables. Instances of "$$" are escaped to "$".
func ExpandNoEscape ¶ added in v0.44.9
ExpandNoEscape behaves the same as Expand but without replacing "$$" with "$".
Types ¶
type Envars ¶
Envars is a convenience alias
func (Envars) Apply ¶
Apply ops to these Envars and return the resulting Transform.
Envars are not modified.
type Force ¶
Force set/unset an environment variable without preserving or restoring its previous value.
type Op ¶
type Op interface {
fmt.Stringer
Envar() string
// Apply changes to transform.
//
// This may also add/remove extra housekeeping variables to support Revert.
Apply(transform *Transform)
// Revert the changes made by Apply.
Revert(transform *Transform)
// contains filtered or unexported methods
}
Op is an operation on an environment variable.
type Ops ¶
type Ops []Op
Ops to apply to a set of environment variables.
func Infer ¶
Infer uses simple heuristics to build a sequence of transformations for environment variables.
Currently this consists of detecting prepend/append to :-separated lists, set and unset.
func UnmarshalOps ¶ added in v0.15.2
UnmarshalOps from JSON.
type Transform ¶
type Transform struct {
// contains filtered or unexported fields
}
Transform encapsulates low-level transformations on an existing environment.
func (*Transform) Changed ¶
Changed returns the set of changed Envars.
If "undo" is true the returned Envars will include undo state.