amarin / env

Env variables unmarshaler for go structures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

= env

Golang env package adds ability to load structure configurable attributes from environment variables. It uses structure attributes tags to attach env variable name to attribute.

Loadable attributes should be exported (name started from upper case letter).

Example usage:

import "github.com/amarin/env"

type MyStruct struct {
    AttributeA string `env:"MYSTRUCT_A"`
}

func NewMyStruct() *MyStruct {
    myStruct := &MyStruct{}
    env.Load(myStruct)
    
    return myStruct
}

NOTE: Currently only string, int and bool fields processed.

About

Env variables unmarshaler for go structures


Languages

Language:Go 100.0%