Documentation
¶
Index ¶
- Constants
- Variables
- func Exist(e ...string) bool
- func ExpandValueEnv(value string) (realValue string)
- func ExpandValueEnvForMap(m map[string]interface{}) map[string]interface{}
- func GetEnv(e ...string) string
- func Init() (err error)
- func IsDebug() bool
- func IsDev() bool
- func IsProd() bool
- func IsRelease() bool
- func IsStag() bool
- func IsTest() bool
- func LoadFile(envFiles ...string) (err error)
- func Parse() map[string]string
- func SetDebug() (err error)
- func SetDebugFalse() (err error)
- func SetEnv(e, v string) error
- func SetSkipErrorFile() (err error)
- type Env
Constants ¶
View Source
const EnvPrefixSeparator = "_"
Variables ¶
View Source
var Cfg = struct { Prefix string Service string Version string Env string }{ Prefix: "", Service: "", Version: "v0.0.1.t", Env: RunMode.Dev, }
Cfg default config
View Source
var RunMode = struct { Dev string Test string Stag string Prod string Release string }{ Dev: "dev", Test: "test", Stag: "stag", Prod: "prod", Release: "release", }
Env env配置
Functions ¶
func ExpandValueEnv ¶
ExpandValueEnv 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.ExpandValueEnv("${GOPATH}") // return the GOPATH environment variable.
v2 := config.ExpandValueEnv("${GOAsta||/usr/local/go}") // return the default value "/usr/local/go/".
v3 := config.ExpandValueEnv("Astaxie") // return the value "Astaxie".
func ExpandValueEnvForMap ¶
ExpandValueEnvForMap convert all string value with environment variable.
Types ¶
Click to show internal directories.
Click to hide internal directories.