env

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package env parses, loads, and applies Ohm environment files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFiles

func DefaultFiles(environment string) []string

DefaultFiles returns the default environment file load order.

func Parse

func Parse(r io.Reader) (map[string]string, error)

Parse reads environment variables from r.

func ParseNamed

func ParseNamed(name string, r io.Reader) (map[string]string, error)

ParseNamed reads environment variables from r and uses name in parse errors.

Types

type Loader

type Loader struct {
	Dir         string
	Environment string
	Files       []string
	LookupEnv   func(string) (string, bool)
	SetEnv      func(string, string) error
}

Loader reads Ohm environment files from a directory.

func (Loader) Apply

func (l Loader) Apply(vars map[string]string) error

Apply sets loaded values without overwriting existing process environment values.

func (Loader) Load

func (l Loader) Load() (map[string]string, error)

Load reads configured environment files and merges them in load order.

func (Loader) LoadAndApply

func (l Loader) LoadAndApply() (map[string]string, error)

LoadAndApply loads environment files and applies them to the process environment.

type ParseError

type ParseError struct {
	Name    string
	Line    int
	Message string
}

ParseError describes an invalid line in an environment file.

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns the formatted parse location and message.

Jump to

Keyboard shortcuts

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