Documentation
¶
Overview ¶
Package genv is a library for Go (golang) that makes it easy to read and use environment variables in your projects. It also allows environment variables to be loaded from the .env file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EnvVariables = make(map[string]*EnvVariable)
EnvVariables is where environment variables are stored.
Functions ¶
This section is empty.
Types ¶
type EnvVariable ¶ added in v1.0.1
EnvVariable contains information about the environment variable, such as key, value, and default value.
func Key ¶
func Key(key string) *EnvVariable
Key is used to determine the path of the environment variable to be accessed.
genv.Key("env-key").String()
func (*EnvVariable) Bool ¶ added in v1.0.1
func (e *EnvVariable) Bool() bool
Bool method is used for environment variables of type bool.
genv.Key("env-key").Bool()
func (*EnvVariable) Default ¶ added in v1.0.1
func (e *EnvVariable) Default(defaultValue interface{}) *EnvVariable
Default is used to specify the default value for the environment variable to be accessed.
genv.Key("env-key").Default("defaultValue").String()
func (*EnvVariable) Float ¶ added in v1.0.1
func (e *EnvVariable) Float() float64
Float method is used for environment variables of type float.
genv.Key("env-key").Float()
func (*EnvVariable) Int ¶ added in v1.0.1
func (e *EnvVariable) Int() int
Int method is used for environment variables of type int.
genv.Key("env-key").Int()
func (*EnvVariable) String ¶ added in v1.0.1
func (e *EnvVariable) String() string
String method is used for environment variables of type string. It automatically trims single or double quotes from the beginning and end of the value.
genv.Key("env-key").String()
func (*EnvVariable) Update ¶ added in v1.0.1
func (e *EnvVariable) Update(value interface{})
Update is used to update the value of the corresponding environment variable.
genv.Key("env-key").Update("updatedValue")