Documentation ¶
Index ¶
- Variables
- func Expand(value string) string
- func Get(names ...string) string
- func GetBoolVal(val *bool, names ...string)
- func GetFloatVal(val *float64, names ...string)
- func GetIntVal(val *int, names ...string)
- func GetWith(val *string, names ...string)
- func List() map[string]string
- func Lookup(key string) (string, bool)
- func Set(key, value string) error
- func Unsetenv(key string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var Home = lavax.FirstNotEmpty( homedir.HomeDir, func() string { var h, err = dir.Dir() xerror.Exit(err) return h }, )
Home the home directory for the current user
View Source
var Hostname = lavax.FirstNotEmpty( func() string { return os.Getenv("HOSTNAME") }, func() string { var h, err = os.Hostname() xerror.Exit(err) return h }, )
View Source
var Namespace = lavax.FirstNotEmpty( func() string { return os.Getenv("NAMESPACE") }, func() string { return os.Getenv("POD_NAMESPACE") }, func() string { if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { if ns := strings.TrimSpace(string(data)); len(ns) > 0 { return ns } } return "" }, func() string { return "default" }, )
View Source
var Prefix = os.Getenv(strings.ToUpper("env_prefix"))
Prefix 系统环境变量前缀
View Source
var Pwd = xerror.PanicStr(os.Getwd())
Pwd 当前目录
Functions ¶
func Expand ¶
Expand returns value of convert with environment variable. Return environment variable if value start with "${" and end with "}". Return default value if environment variable is empty or not exist.
It accept value formats "${env}" , "${env|}}" , "${env||defaultValue}" , "defaultvalue". Examples:
v1 := config.Expand("${GOPATH}") // return the GOPATH environment variable. v2 := config.Expand("${GOPATH||/usr/local/go}") // return the default value "/usr/local/go/". v3 := config.Expand("Astaxie") // return the value "Astaxie".
func GetBoolVal ¶
func GetFloatVal ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.