dotenv

package
v1.0.0-beta.37 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dotenv reads the env vars of an app from one .env text, KEY=value per line, writes them as one, and says what replacing them with such a text changes. The CLI, the TUI, the hub and the daemon share it, so a text means the same everywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(env map[string]string) string

Format writes env as a .env text Parse reads back exactly, and docker compose too: one KEY="value" per line, sorted by key, with \, ", $ and line breaks escaped, so compose fills in no ${VAR} of a value.

func Parse

func Parse(text string) (map[string]string, error)

Parse reads a .env text. Empty lines and lines starting with # are skipped, "export " in front of a key is allowed. A value may be bare, in single quotes (taken as it is) or in double quotes, where \n, \", \\ and \$ stand for a line break, a quote, a backslash and a dollar; \r for a carriage return. An error names the line by its number only, never by what is on it: a broken line may hold a secret.

Types

type Change

type Change struct {
	Added    []string `json:"added"`
	Replaced []string `json:"replaced"`
	Removed  []string `json:"removed"`
}

Change is what replacing the env vars with others does, by key, sorted. Replaced are the keys there were and that come again: moin never reads a value back, so it cannot tell a new value from the same one.

func Diff

func Diff(current []string, next map[string]string) Change

Diff compares the keys there are with the env vars that replace them.

func (Change) None

func (c Change) None() bool

None reports whether the change changes nothing.

func (Change) String

func (c Change) String() string

String says the change in one line: "adds A; replaces B; removes C".

Jump to

Keyboard shortcuts

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