Versions in this module Expand all Collapse all v1 v1.0.0 May 13, 2026 Changes in this version + var ErrAssertionFailed = errors.New("dotenv: ${VAR:?...} assertion failed") + var ErrExpansion = &ExpansionError + var ErrFileTooLarge = errors.New("dotenv: file size exceeds limit") + var ErrInvalidKey = errors.New("dotenv: invalid key") + var ErrLineTooLong = errors.New("dotenv: line length exceeds limit") + var ErrMaxExpansionDepth = errors.New("dotenv: variable-expansion depth limit exceeded") + var ErrParse = &ParseError + var ErrUnsetVariable = errors.New("dotenv: variable referenced in expansion is unset") + func IsValidKey(key string) bool + func Load(path string, opts ...ParseOption) (map[string]string, error) + func Marshal(m map[string]string) ([]byte, error) + func Write(path string, m map[string]string) error + type Entry struct + Key string + Kind EntryKind + Pos Position + Value string + type EntryKind int + const EntryAssignment + const EntryBlank + const EntryComment + type ExpansionError struct + Cause error + Pos Position + Reason string + Variable string + func (*ExpansionError) Is(target error) bool + func (e *ExpansionError) Error() string + func (e *ExpansionError) Unwrap() error + type File struct + func Parse(data []byte, opts ...ParseOption) (*File, error) + func (f *File) Delete(key string) bool + func (f *File) Entries() []Entry + func (f *File) Get(key string) (value string, ok bool) + func (f *File) Keys() []string + func (f *File) Marshal() ([]byte, error) + func (f *File) Path() string + func (f *File) Set(key, value string) + func (f *File) Source() *Source + func (f *File) ToMap() map[string]string + type LintIssue struct + Message string + Pos Position + Rule string + Severity Severity + func Lint(data []byte, opts ...ParseOption) ([]LintIssue, error) + type ParseError struct + Message string + Pos Position + func (*ParseError) Is(target error) bool + func (e *ParseError) Error() string + type ParseOption func(*parseOptions) + func WithBackticks() ParseOption + func WithExpand() ParseOption + func WithExpandFromOSEnv() ParseOption + func WithExpansionParent(parent VarLookup) ParseOption + func WithMaxExpansionDepth(n int) ParseOption + func WithMaxFileSize(n int64) ParseOption + func WithMaxLineLength(n int) ParseOption + func WithRelaxedNames() ParseOption + func WithStrictDotenv() ParseOption + func WithStrictExpansion() ParseOption + type Position struct + Column int + File string + Line int + Offset int + func (p Position) String() string + type Severity int + const SeverityError + const SeverityWarning + func (s Severity) String() string + type Source struct + func MapSource(m map[string]string) *Source + func NewReaderSource(r io.Reader, opts ...ParseOption) (*Source, error) + func NewSource(path string, opts ...ParseOption) (*Source, error) + func (s *Source) Keys() []string + func (s *Source) Lookup(key string) (value string, ok bool) + func (s *Source) ToMap() map[string]string + type VarLookup interface + Lookup func(key string) (value string, ok bool)