Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupFile ¶ added in v0.1.0
func PatchAll ¶
func PatchAll(path string, patches map[string]string, comments []CommentBlock) error
PatchAll reads existing env from path, merges patches, and writes atomically via a temp file + rename. If path does not exist, starts from an empty env. comments are placed per mergeComments and may be nil (no-op). The original file's permissions are preserved.
Types ¶
type CommentBlock ¶ added in v0.4.0
type CommentBlock struct {
Lines []string
Anchor string // key the block is attached to; empty for detached blocks
After bool // block goes directly below Anchor instead of above it
Header bool // detached block located before the first key
}
CommentBlock is a contiguous run of full-line comments from an env file.
func ScanComments ¶
func ScanComments(path, mode string) ([]CommentBlock, error)
ScanComments reads path and returns its full-line comment blocks per mode. mode: "all" | "blocks-only" | anything else → nil, nil
A block directly followed by a key line is anchored above that key. A block directly preceded by a key line and followed by a blank line or EOF is anchored below the preceding key. Any other block is detached; detached blocks before the first key are marked as Header.