zk/internal/util/os/os.go
Michael McDonagh 0eaf26483f
Remove references to old repo (#373)
Finalise transfer from old repo (github.com/mickael-menu/zk) to new (github.com/zk-org/zk)

Co-authored-by: tjex <tjex@tjex.net>
2024-01-10 22:47:22 +01:00

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
}