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

envhelpers

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

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

Expand replaces ${var} (and only that) in the string based on the mapping function. This signature is identical to the one in the Go standard library, but has a more restrictive scope with less ambiguity. The value inside ${} must match \w+ (see regexp.MatchString).

A special form of environment variable syntax is supported to allow for removing surrounding quoutes (both single and double), useful to setting numeric values in TOML/JSON config files etc. Use the "@U" suffix to signal unquoting, e.g. `"${myvar@U}"` or `'${myvar@U}'`. Note that when using the "@U" suffix, the variable expression needs to be surrounded by quoutes.

func SetEnvVars

func SetEnvVars(oldVars *[]string, keyValues ...string)

SetEnvVars sets vars on the form key=value in the oldVars slice.

func SplitEnvVar

func SplitEnvVar(v string) (string, string)

SplitEnvVar splits an env var into key and value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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