You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zk/internal/util/os/os.go

28 lines
535 B
Go

package os
import (
"os"
"strings"
"github.com/zk-org/zk/internal/util/opt"
)
// Getenv returns an optional String for the environment variable with given
// key.
func GetOptEnv(key string) opt.String {
if value, ok := os.LookupEnv(key); ok {
return opt.NewNotEmptyString(value)
}
return opt.NullString
}
// Env returns a map of environment variables.
func Env() map[string]string {
env := map[string]string{}
for _, e := range os.Environ() {
pair := strings.SplitN(e, "=", 2)
env[pair[0]] = pair[1]
}
return env
}