Package env provides tools for working with environment-variables, for the Go programming language.
Find a file
2026-02-25 19:52:30 -08:00
internal initial commits 2025-09-04 11:24:06 -07:00
get.go refactor 2025-09-10 06:24:31 -07:00
getelse.go docs 2025-09-09 13:14:12 -07:00
go.mod added support for []string 2026-02-25 19:52:30 -08:00
go.sum added support for []string 2026-02-25 19:52:30 -08:00
LICENSE initial commits 2025-09-04 11:09:47 -07:00
mustget.go refactor 2025-09-10 06:24:31 -07:00
README.md initial commits 2025-09-04 12:32:11 -07:00
type.go refactor 2025-09-10 06:24:31 -07:00
vars.go initial commits 2025-09-04 11:32:34 -07:00

go-env

Package env provides tools for working with environment-variables, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-env

GoDoc

Examples

Here is an example of getting the value of the environment-variable PORT as a uint16:

tcpport, found := env.Get[uint16]("PORT")

Here is an example of getting the value of the environment-variable PORT as a uint16, and it doesn't exist or isn't a uint16 number, then defaulting it to 8080:

tcpport := env.GetElse[uint16]("PORT", 8080)

Here is an example of getting the value of the environment-variable SHELL as a string:

shell, found := env.Get[string]("SHELL")

Import

To import package env use import code like the following:

import "github.com/reiver/go-env"

Installation

To install package env do the following:

GOPROXY=direct go get github.com/reiver/go-env

Author

Package env was written by Charles Iliya Krempeaux