dotenv

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package dotenv parses the subset of .env syntax `notenv import` accepts. The dialect is documented and deliberately small — an importer for secrets must never guess:

  • blank lines and full-line `#` comments are skipped; an unquoted value may carry a trailing comment when whitespace precedes the `#`
  • an optional `export ` prefix is dropped
  • unquoted values are trimmed of surrounding whitespace
  • single-quoted values are literal, double-quoted values understand the \n, \t, \", \\ escapes; both may span multiple lines
  • there is no variable expansion of any kind: a secrets file is not a shell script, and silently expanding `$X` would corrupt real values

Anything else — a line without `=`, an unterminated quote, a stray escape — fails the parse with its line number, so an import is all-or-nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Key   string
	Value string
	Line  int
}

Pair is one assignment, in file order. A key assigned twice appears twice; the caller applies last-wins.

func Parse

func Parse(r io.Reader) ([]Pair, error)

Parse reads assignments from r.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL