varenv

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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ParserFormat string = "VARENV"

ParserFormat defines the standard identifier used to identify system environment variables.

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

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, filter, and map system environment variables into a consolidated application state.

func NewParser

func NewParser() *Parser

NewParser instantiates an unconfigured pointer to an environment variables Parser.

func (*Parser) Read

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

Read intercepts all active system environment variables, filters out keys that do not match the configured application prefix, strips the prefix, and normalizes the hierarchical separators into standard dot-notation format.

Processing features:

  • Trims the mandatory application prefix to clean up the configuration map keys.
  • Automatically handles boundary separators to avoid leading dots (e.g., converts APP_DB to db).
  • Replaces custom layout delimiters with dot notation (e.g., DB_PORT becomes db.port).

Returns a generic string-interface map containing all parsed and matched environment data.

func (*Parser) SetOptions

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

SetOptions executes validation against the incoming criteria. It requires both Prefix and Separator properties to be explicitly defined, establishing a precise lookup filter for environmental keys.

Jump to

Keyboard shortcuts

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