Documentation
¶
Overview ¶
Package dotenv parses a standard `.env` file into ordered key/value entries.
This is the STANDARD dotenv grammar an operator's existing `.env` uses — the onboarding source the source-of-truth ADR fixes as the scaffold path and the import path's dotenv leg. It is deliberately NOT the inverse of compose.EncodeRaw: that encoder emits Compose's `format: raw` (no quoting, no escaping), whereas a hand-written `.env` uses quotes and backslash escapes, so the two are different grammars and live in different packages.
The parser is pure and fail-loud: a malformed line, a duplicate key, or a name outside the canonical grammar is refused BY NAME rather than parsed into something the operator did not write. `#` begins a comment only at the start of a line (after optional leading whitespace); a `#` after an unquoted value is part of the value, never a silently stripped inline comment — silently truncating a value that legitimately contains ` #` is exactly the transformation a secrets tool must not perform. Quote the value to carry a leading `#` or surrounding whitespace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Refusal ¶
Refusal names one entry Encode could not represent.
func Encode ¶
Encode renders entries as a dotenv document that Parse reads back byte-exact. Values that the unquoted grammar would alter - surrounding whitespace (Parse trims it), a leading quote, a `#`, a backslash, a control character or a newline - are double-quoted with the escapes parseDoubleQuoted understands; every other value is written bare. This is deliberately NOT the Compose renderer's raw encoding: that one is consumed by Compose's `format: raw`, which performs no unquoting, whereas a document written for humans and for `values import --from-dotenv` must survive the round trip. A NUL byte cannot be carried by either grammar and is refused by name.