dotenv

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(environ []string, systemLookup func(string) string, noUnset bool) (map[string]string, error)

All evaluates an array of key=value strings in the dotenv syntax, and return a map of evaluated variables

func AllRaw

func AllRaw(environ []string) map[string]string

Evaluate an array of key=value strings in the dotenv syntax, in raw mode: values are left unprocessed.

func AllWithContext added in v0.21.7

func AllWithContext(own, context []string, systemLookup func(string) string, noUnset bool) (map[string]string, error)

AllWithContext evaluates only the variables defined in own, while making the variables in context available for ${...} expansion (they are not returned). context entries are only expanded if referenced by an own value, so an unrelated unbound context entry never triggers an error. When a name is defined in both, the own value wins.

func Exists

func Exists(environ []string, name string) bool

func Lookup

func Lookup(environ []string, name string, systemLookup func(string) string) (string, bool, error)

Evaluate an array of key=value strings in the dotenv syntax, and return the value of the specified variable

func LookupRaw

func LookupRaw(environ []string, name string) (string, bool)

Evaluate an array of key=value strings in the dotenv syntax, and return the value of the specified variable in raw mode

func LookupWithContext added in v0.21.7

func LookupWithContext(own, context []string, name string, systemLookup func(string) string) (string, bool, error)

LookupWithContext evaluates a single own variable, using context for ${...} expansion. Returns found=false if name is not defined in own.

func StripExportPrefix added in v0.21.4

func StripExportPrefix(line string) string

StripExportPrefix removes an optional leading `export` keyword from a dotenv line. This is a widely supported convention (direnv, `set -a; . ./.env`, shell `source`, and most .env loaders), so `export KEY=value` is treated the same as `KEY=value`.

Types

type GraphEvaluator added in v0.19.1

type GraphEvaluator struct {
	NoUnset bool
	// contains filtered or unexported fields
}

GraphEvaluator evaluates dotenv variables with dependency resolution and cycle detection

func NewGraphEvaluator added in v0.19.1

func NewGraphEvaluator(environ []string, systemLookup func(string) string, noUnset bool) (*GraphEvaluator, error)

NewGraphEvaluator creates a new graph-based evaluator

func (*GraphEvaluator) All added in v0.19.1

func (g *GraphEvaluator) All() (map[string]string, error)

All returns all variables, expanded

func (*GraphEvaluator) Lookup added in v0.19.1

func (g *GraphEvaluator) Lookup(name string) (string, bool, error)

Lookup gets the expanded value of a variable with memoization

Jump to

Keyboard shortcuts

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