envvar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasPlaceholders

func HasPlaceholders(s string) bool

HasPlaceholders returns true if s contains any {{VAR}} patterns.

Types

type Expander

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

Expander replaces {{VAR}} placeholders in strings with values from config env map or OS environment variables. Config values take precedence.

func NewExpander

func NewExpander(configEnv map[string]string) *Expander

NewExpander creates an expander from a config env map. OS environment variables are used as fallback for any key not in the map.

func (*Expander) Collapse

func (e *Expander) Collapse(url string) string

Collapse replaces a known base URL with a {{VAR}} placeholder. Used during recording to make snapshots environment-independent.

func (*Expander) Expand

func (e *Expander) Expand(s string) string

Expand replaces all {{VAR}} placeholders in s with their values. Looks up config env first, then OS env. Unresolved placeholders are left as-is.

func (*Expander) ExpandURL

func (e *Expander) ExpandURL(url string) string

ExpandURL replaces placeholders in a URL string.

Jump to

Keyboard shortcuts

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