envfile

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 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 envfile reads files of environment variables, one NAME=value a line, as the .env files many tools keep beside a project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Var

type Var struct {
	Name  string
	Value string
}

Var is a variable a file sets.

func Parse

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

Parse reads variables from r, in the order they are written:

# a comment
NAME=value
export NAME=value
NAME="a value with spaces, \n for a newline and \" for a quote"
NAME='a value taken as it is, $ and \ included'
NAME=value # a comment after a value that is not quoted

A value that is not quoted has the spaces around it removed. A value in double quotes may go on over several lines. Nothing is expanded: $OTHER in a value is those characters. A name written twice is returned twice, for the last to win.

An error starts with the line it is about, as "3: ...".

func Read

func Read(path string) ([]Var, error)

Read reads the variables of the file at path, in the order they are written. An error names the file and the line.

Jump to

Keyboard shortcuts

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