dotenv

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package dotenv parses the subset of .env syntax `notenv namespace 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, \r, \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