Help us shape the future of Go! Take the 2026 Go Developer Survey

envfile

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

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

Parse reads .env content into a key-value map. content is the raw file content; returns parsed key/value pairs or an error.

func Patch

func Patch(content string, updates map[string]string) string

Patch updates .env content with the provided key/value pairs. content is the existing file content; updates supplies key/value pairs to merge. New keys are appended in sorted order and leave the result ending in a newline, so a later shell append cannot merge onto the last value; otherwise the input's final-newline state is kept.

Types

type Assignment added in v0.24.1

type Assignment struct {
	// Export reports whether the line starts with "export ".
	Export bool
	Key    string
	// Value is the decoded value.
	Value string
	// Comment is the raw trailing comment after a quoted value, including its
	// leading whitespace; it is empty when the value is unquoted or has no comment.
	Comment string
}

Assignment is one KEY=value line of .env content.

func ParseLine added in v0.24.1

func ParseLine(line string) (Assignment, bool, error)

ParseLine parses a single .env line. line is the raw line; returns the assignment, a boolean for presence (false for blank and comment-only lines), and an error for invalid syntax.

Jump to

Keyboard shortcuts

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