ubgo is in early alpha: libraries and APIs may still change.

Skip to content
ubgo Alpha

dotenv

.env parser and editor that keeps comments, order and quoting, plus the dotenvctl CLI.

go get github.com/ubgo/dotenv
Language
Go
Go version
1.22
Core deps
0 direct
Latest tag
v0.1.1
License
Apache-2.0
Go modules
2

Code from the README

f, err := dotenv.Open(".env")     // a missing file is not an error
if err != nil {
	return err
}

v, ok := f.Get("DATABASE_URL")
f.Has("DATABASE_URL")
f.Keys()      // active keys, in file order, deduplicated
f.Pairs()     // active pairs, in file order, duplicates included
f.Map()       // effective view: last occurrence wins

From the dotenv README.

At a glance (from the README)

FamilySemanticsUse for
Set, SetAfter, SetBeforeupsert — guarantees one active entry; updates in place if the key existsediting
Append, InsertAfter, InsertBeforeliteral — places exactly what you pass, duplicates includedgenerating