Skip to content

API Reference ​

Complete API reference documentation for the env library.

Core API ​

Types and Interfaces ​

Symbol Index ​

The major symbols from every API reference page, grouped by function, each linking straight to its documentation. Same-named methods and package functions (e.g. GetString) get one row each under "Package-Level Functions" and "Loader Methods"; symbols marked (unexported) are internal library names that cannot be referenced through the env package.

Package-Level Functions ​

SymbolDescriptionPage
LoadInit default loaderfunctions
LoadWithConfigInit with Configfunctions
ResetDefaultLoaderReset default loaderfunctions
GetStringRead stringfunctions
GetIntRead int64functions
GetBoolRead boolfunctions
GetUint64Read uint64functions
GetFloat64Read float64functions
GetDurationRead durationfunctions
GetSliceGeneric slice readfunctions
GetSliceFromSlice from instancefunctions
GetSecureRead secretfunctions
LookupKey existence checkfunctions
KeysAll key namesfunctions
AllFull key/value mapfunctions
LenVariable countfunctions
SetSet variablefunctions
DeleteDelete variablefunctions
ValidateCheck required keysfunctions
ParseIntoMap to structfunctions
MarshalSerialize to stringfunctions
UnmarshalMapParse to mapfunctions
UnmarshalStructParse into structfunctions
UnmarshalIntoFill struct from mapfunctions
MarshalStructStruct to mapfunctions
IsMarshalErrorMarshal error checkfunctions

Loader Methods ​

SymbolDescriptionPage
NewCreate Loaderloader
LoadFilesLoad multi-format filesloader
GetStringRead stringloader
GetIntRead int64loader
GetBoolRead boolloader
GetUint64Read uint64loader
GetFloat64Read float64loader
GetDurationRead durationloader
GetSecureRead secret copyloader
LookupKey existence checkloader
SetSet variableloader
DeleteDelete variableloader
KeysAll key namesloader
AllFull key/value maploader
LenVariable countloader
ApplyApply to os.Environloader
IsAppliedApplied flagloader
LoadTimeLast load timeloader
ConfigRead-only config copyloader
ValidateCheck required keysloader
ParseIntoMap to structloader
CloseClose and zeroloader
IsClosedClosed flagloader

Config ​

SymbolDescriptionPage
ConfigConfiguration structconfig
FileConfig, ValidationConfig, LimitsConfig, JSONConfig, YAMLConfig, ParsingConfig, ComponentConfigSeven nested sectionsconfig
Filenames, OverwriteExisting, MaxFileSize, KeyPattern, AuditEnabled, etc.All config fieldsconfig
ValidateValidate configconfig
IsZeroZero-value checkconfig
ExpansionScopeExpansion scope enumconfig
ExpansionFileThenProcess, ExpansionFileOnlyScope constantsconfig

Presets, Factory, and Formats ​

SymbolDescriptionPage
DefaultConfigSafe defaultsconfig
DevelopmentConfigRelaxed dev presetconfig
TestingConfigTest-isolation presetconfig
ProductionConfigStrict prod presetconfig
ComponentFactoryComponent factory typefactory
ValidatorFactory: validatorfactory
AuditorFactory: auditorfactory
ExpanderFactory: expanderfactory
CloseFactory: releasefactory
IsClosedFactory: closed flagfactory
RegisterParserRegister parserfactory
ForceRegisterParserOverride builtinfactory
ParserFactoryParser factory sigfactory
DetectFormatDetect file formatfactory
FileFormatFormat enumfactory
FormatAuto, FormatEnv, FormatJSON, FormatYAMLBuiltin format constantsfactory
String (FileFormat method)Format namefactory
OSFileSystemOS implementationfactory
DefaultFileSystemDefault instancefactory

SecureValue and Memory Locking ​

SymbolDescriptionPage
SecureValueSecure value typesecure-value
NewSecureValueCreate secure valuesecure-value
NewSecureValueStrictError on lock failuresecure-value
StringMasked stringersecure-value
RevealRead plaintextsecure-value
BytesByte copysecure-value
LengthValue lengthsecure-value
MaskedMasked formsecure-value
MarshalJSONMasked JSON outputsecure-value
MarshalTextMasked text outputsecure-value
CloseZero, no pool returnsecure-value
ReleaseZero and pool returnsecure-value
IsClosedClosed flagsecure-value
IsMemoryLockedMemory lock statesecure-value
MemoryLockErrorLock errorsecure-value
SetMemoryLockEnabledGlobal lock switchsecure-value
IsMemoryLockEnabledQuery global switchsecure-value
SetMemoryLockStrictStrict-mode warningssecure-value
IsMemoryLockStrictQuery strict modesecure-value
IsMemoryLockSupportedPlatform supportsecure-value

Security Utilities ​

SymbolDescriptionPage
ClearBytesZero byte slicesecure-value
IsSensitiveKeySensitive key checksecure-value
MaskValueMask value by keysecure-value
MaskKeyMask key namesecure-value
SanitizeForLogLog redactionsecure-value
MaskSensitiveInStringTruncate long stringssecure-value

Auditing ​

SymbolDescriptionPage
AuditLoggerMinimal audit interfaceinterfaces
FullAuditLoggerFull audit interfaceinterfaces
AuditHandlerHandler interfaceinterfaces
AuditEventAudit event structinterfaces
AuditActionAction typeinterfaces
ActionLoad, ActionParse, ActionGet, ActionSet, ActionDelete, ActionValidate, ActionExpand, ActionSecurity, ActionError, ActionFileAccessTen action constantsinterfaces
NewJSONAuditHandlerJSON handlerfactory
NewLogAuditHandlerStdlib-log handlerfactory
NewChannelAuditHandlerChannel handlerfactory
NewNopAuditHandlerNo-op handlerfactory
NewCloseableChannelHandler, CloseableChannelHandlerSelf-owned channel handlerfactory
JSONAuditHandler, LogAuditHandler, ChannelAuditHandler, NopAuditHandlerHandler implementationsinterfaces

Errors and Sentinels ​

SymbolDescriptionPage
ErrFileNotFound, ErrFileTooLargeFile sentinelsconstants
ErrLineTooLong, ErrInvalidKey, ErrDuplicateKeyParse sentinelsconstants
ErrForbiddenKey, ErrSecurityViolation, ErrInvalidValueSecurity sentinelsconstants
ErrExpansionDepthExpansion sentinelconstants
ErrMaxVariablesLimit sentinelconstants
ErrClosed, ErrInvalidConfig, ErrAlreadyInitialized, ErrNotInitialized, ErrMissingRequiredState sentinelsconstants
ErrValidateRequiredUnsupportedAdapter sentinelconstants
ParseErrorParse error typeconstants
ValidationErrorValidation error typeconstants
SecurityErrorSecurity error typeconstants
FileErrorFile error typeconstants
ExpansionErrorExpansion error typeconstants
ExpansionErrorKind, ExpansionDepthKind, ExpansionRequiredKindError kind constantsconstants
JSONErrorJSON parse errorconstants
YAMLErrorYAML parse errorconstants
MarshalErrorMarshal error typeconstants

Constants and Limits ​

SymbolDescriptionPage
DefaultMaxFileSize, DefaultMaxLineLength, DefaultMaxKeyLength, DefaultMaxValueLength, DefaultMaxVariables, DefaultMaxExpansionDepthDefault limit constantsconstants
DefaultKeyPatternDefault key patternconstants
defaultForbiddenKeys (unexported)Builtin forbidden keysconstants
internal.Patterns (unexported)Sensitive key patternsconstants
Hard limits (unexported)100MB, 64KB, etc.constants

Interfaces ​

SymbolDescriptionPage
EnvLoaderComposite loader interfaceinterfaces
EnvFileLoaderFile loading interfaceinterfaces
EnvGetterRead-only access interfaceinterfaces
EnvSetterWrite access interfaceinterfaces
EnvApplicatorApply to system envinterfaces
EnvCloserResource release interfaceinterfaces
ValidatorComposite validation interfaceinterfaces
KeyValidatorKey validation interfaceinterfaces
ValueValidatorValue validation interfaceinterfaces
RequiredValidatorRequired-keys interfaceinterfaces
VariableExpanderVariable expansion interfaceinterfaces
EnvParserParser interfaceinterfaces
EnvStorageStorage backend interfaceinterfaces
MarshalerCustom serializationinterfaces
UnmarshalerCustom deserializationinterfaces
FileSystemFilesystem abstractioninterfaces
FileFile operation interfaceinterfaces