Help us shape the future of Go! Take the 2026 Go Developer Survey

envsubst

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 10 Imported by: 224

README

envsubst

envsubst is a Go package for expanding variables in a string using ${var} syntax. Includes support for bash string replacement functions.

Documentation

Documentation can be found on GoDoc.

Supported Functions

  • ${var^}
  • ${var^^}
  • ${var,}
  • ${var,,}
  • ${var:position}
  • ${var:position:length}
  • ${var#substring}
  • ${var##substring}
  • ${var%substring}
  • ${var%%substring}
  • ${var/substring/replacement}
  • ${var//substring/replacement}
  • ${var/#substring/replacement}
  • ${var/%substring/replacement}
  • ${#var}
  • ${var=default}
  • ${var:=default}
  • ${var:-default}

Unsupported Functions

  • ${var-default}

  • ${var+default}

  • ${var:?default}

  • ${var:+default}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(s string, mapping func(string) string) (string, error)

Eval replaces ${var} in the string based on the mapping function.

func EvalEnv

func EvalEnv(s string) (string, error)

EvalEnv replaces ${var} in the string according to the values of the current environment variables. References to undefined variables are replaced by the empty string.

Types

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template is the representation of a parsed shell format string.

func Parse

func Parse(s string) (t *Template, err error)

Parse creates a new shell format template and parses the template definition from string s.

func ParseFile

func ParseFile(path string) (*Template, error)

ParseFile creates a new shell format template and parses the template definition from the named file.

func (*Template) Execute

func (t *Template) Execute(mapping func(string) string) (str string, err error)

Execute applies a parsed template to the specified data mapping.

Directories

Path Synopsis
cmd
envsubst command

Jump to

Keyboard shortcuts

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