main
1package env
2
3import (
4 "os"
5 "strings"
6)
7
8func Fetch(key string, defaultValue string) string {
9 if x := os.Getenv(key); x != "" {
10 return x
11 }
12 return defaultValue
13}
14
15func Variables() Vars {
16 items := Vars{}
17 for _, line := range os.Environ() {
18 segments := strings.SplitN(line, "=", 2)
19 items[segments[0]] = segments[1]
20 }
21 return items
22}