posix

package module
v0.0.0-...-256a914 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 8 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(s string, mapping Getter) (string, error)

Expand replaces ${var} or $var in the string based on the mapping. Supports most Posix shell exapansions:

Default: ${param:-word} ${param-word}

Assign default: ${param:=word} ${param=word}

Error: ${param:?error} ${param?error}

Alternative: ${param:+word} ${param+word}

See: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

func ExpandEnv

func ExpandEnv(s string) (string, error)

ExpandEnv replaces ${var} or $var in the string according to the values of the current environment variables.

Types

type Func

type Func func(string) string

Func implements the Getter interface for simple lookup functions.

func (Func) Get

func (f Func) Get(s string) (string, bool)

type Getter

type Getter interface {
	Get(key string) (value string, exists bool)
}

Getter is the interface for mapping key to value lookups.

type Map

type Map map[string]string

Map implements the Getter interface for map[string]string

func (Map) Get

func (m Map) Get(k string) (string, bool)

type Pos

type Pos int

type RWMap

type RWMap map[string]string

RWMap implements the Getter and Setter interfaces for map[string]string.

func (RWMap) Get

func (m RWMap) Get(k string) (string, bool)

func (RWMap) Set

func (m RWMap) Set(k, v string) error

type Setter

type Setter interface {
	Set(key string, value string) error
}

Setter is the interface for mutable mappings to update a key.

Jump to

Keyboard shortcuts

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