github.com/sandwich-go/boost@v1.3.29/xos/env.go (about) 1 package xos 2 3 import "os" 4 5 // EnvGet 获取环境变量值,如果未找到,则返回 def 值 6 func EnvGet(key string, def ...string) string { 7 v, ok := os.LookupEnv(key) 8 if !ok && len(def) > 0 { 9 return def[0] 10 } 11 return v 12 }