mirror of
https://github.com/mickael-menu/zk
synced 2024-11-19 03:25:40 +00:00
0eaf26483f
Finalise transfer from old repo (github.com/mickael-menu/zk) to new (github.com/zk-org/zk) Co-authored-by: tjex <tjex@tjex.net>
28 lines
535 B
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
|
|
}
|