dotenv

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ParserFormat string = "ENV"

ParserFormat defines the standard identifier and file extension target for this provider.

View Source
const XERR_PKGCTX_PARSER xerrors.ErrorCode = "XCONFIG.PARSER.DOTENV"

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

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

Parser implements the xconfig.Parser interface to read, tokenize, and ingest standard key-value ".env" configuration files.

func NewParser

func NewParser() *Parser

NewParser instantiates an unconfigured pointer to a Parser.

func (*Parser) Read

func (o *Parser) Read() (map[string]any, error)

Read processes all matched configuration files, parses their text lines sequentially, converts valid assignments into a generic data map, and normalizes key hierarchies.

Parsing features:

  • Skips empty lines and comment lines starting with '#'.
  • Strips optional POSIX shell "export " statements.
  • Trims enclosing single (') or double (") quotes from text values.
  • Transforms structural delimiters (e.g., "APP_DB_PORT" with Separator "_" becomes "app.db.port").

Returns a merged generic map of strings, or an error if any file read or scanning operation fails.

func (*Parser) SetOptions

func (o *Parser) SetOptions(opts xconfig.Options) error

SetOptions executes strict path and naming validations against the incoming criteria. It configuration targets must satisfy single-path exclusivity (File vs Dir vs ConfigPath) and must provide valid Prefix and Separator tokens required for environment variables mapping.

Jump to

Keyboard shortcuts

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