Documentation
¶
Overview ¶
Package envutil holds the small, shared environment-handling helpers the build, deploy, and host-launch paths all need: a minimal .env parser and two env-overlay merges whose precedence is encoded in the name. Factoring them here ends a duplication where the same operation name (mergeEnv) meant opposite precedence in different packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeBaseWins ¶
MergeBaseWins layers extra KEY=VALUE pairs onto a base os.Environ() slice with base winning on key conflict (so a developer's shell override always wins). Non-conflicting extras are appended. Returns a fresh slice safe to assign to cmd.Env.
func MergeExtraWins ¶
MergeExtraWins layers extra KEY=VALUE pairs onto a base os.Environ() slice with extra winning on key conflict. Used where the overlay (env_file / BuildEnv) is meant to be authoritative for the variables it declares and the parent process's env is background context. Returns a fresh slice safe to assign to cmd.Env.
func ParseDotEnv ¶
ParseDotEnv parses a .env file (KEY=VALUE per line, # comments, trailing whitespace trimmed) into a map. Quoted values ("VALUE", 'VALUE') have their outer quotes stripped. An optional leading "export " is stripped. Missing file returns os.ErrNotExist (wrapped) so callers can treat absence as non-fatal.
Intentionally minimal — we don't expand $VARS or `${VAR:-default}` shell features. Projects needing those should use direnv or a wrapper script; this helper is just enough for the common "DATABASE_URL=postgres://..." case the host-mode loop and the External deploy env_file overlay need.
Types ¶
This section is empty.