envfile

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package envfile loads simple dotenv-style files without overriding process environment values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupPath

func LookupPath(projectRoot string, explicit string) (string, bool, error)

LookupPath resolves the env file for a project root. explicit wins. Without an explicit path, .env.<GOWDK_ENV> wins over .env when it exists.

Types

type Entry

type Entry struct {
	Name  string
	Value string
}

Entry is one parsed env-file assignment.

func ParseFile

func ParseFile(path string) ([]Entry, error)

ParseFile parses KEY=value and export KEY=value lines. Values may be quoted with single or double quotes. Blank lines and # comments are ignored.

type LoadResult

type LoadResult struct {
	Path     string
	Loaded   bool
	Applied  []string
	Skipped  []string
	Explicit bool
}

LoadResult describes one env-file load without exposing values.

func LoadIntoEnv

func LoadIntoEnv(path string, explicit bool) (LoadResult, error)

LoadIntoEnv loads path and sets only names that are not already present in the process environment. Existing process values always win, including a value changed with os.Setenv after a previous load: a reload only overwrites a name whose current value is still the one this loader last applied.

Jump to

Keyboard shortcuts

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