1
0
Fork
You've already forked go-env
0
Package env provides tools for working with environment-variables, for the Go programming language.
  • Go 100%
Find a file
2026年07月14日 10:52:02 -07:00
internal initial commits 2025年09月04日 11:24:06 -07:00
get.go refactor 2025年09月10日 06:24:31 -07:00
get_nothing_test.go tests 2026年07月14日 10:41:58 -07:00
get_something_test.go tests 2026年07月14日 10:36:02 -07:00
getelse.go docs 2025年09月09日 13:14:12 -07:00
getoptional.go fix 2026年07月14日 10:52:02 -07:00
getoptional_nothing_test.go tests 2026年07月14日 10:05:36 -07:00
getoptional_something_test.go tests 2026年07月14日 10:29:31 -07:00
go.mod go.* 2026年07月14日 10:00:18 -07:00
go.sum go.* 2026年07月14日 10:00:18 -07:00
LICENSE initial commits 2025年09月04日 11:09:47 -07:00
mustget.go erorr 2026年07月14日 07:54:32 -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