envconf/main.go
2021-03-23 10:13:25 +01:00

33 lines
669 B
Go

package envconf
import ("fmt"
"strings"
"os")
const TypeNone = (1 << 1)
const TypeInt = (1 << 2)
const TypeDuration = (1 << 3)
const TypeString = (1 << 4)
type Config struct {
env map[string]map[string]int
}
func NewConfig()(*Config) {
config := new(Config)
config.env = make(map[string]string)
for _,v := range os.Environ() {
splitted := strings.SplitN(v, "=", 2)
if len(splitted) == 2 {
key := strings.ToLower(splitted[0])
strval := splitted[1]
val := make(map[string]int)
val[strval] = TypeNone
env[key] = val
}
}
fmt.Println(config)
}