Documentation
¶
Overview ¶
Package dotenv parses and renders .env files.
Index ¶
Constants ¶
const ( MaxBytes = 16 * 1024 * 1024 MaxEntries = 4096 MaxKeyBytes = 1024 )
Variables ¶
var (
ErrInvalid = errors.New("invalid dotenv")
)
Functions ¶
func Format ¶
Format renders sorted, double-quoted assignments that Parse reads back. It refuses secrets Parse would reject, so a written file can always be read again.
func Parse ¶
Parse accepts assignments, optional export, comments, and single/double quoted values (including multiline values). Double quotes support \\, \" and escaped n/r/t/$; unquoted and single-quoted values remain literal. It never performs variable expansion, reads the environment, or executes code. Duplicate keys are rejected rather than silently overwriting a secret.
The text is UTF-8, or UTF-16 with a byte order mark: what Windows PowerShell 5.1 writes with > or Out-File.
func Text ¶
Text returns a dotenv file's content as UTF-8: UTF-16 that starts with a byte order mark is converted, anything else is returned as it is. Malformed UTF-16 (an odd length or an unpaired surrogate) is ErrInvalid, so a secret is never stored with a replacement character in place of what was there.
Types ¶
This section is empty.