Documentation
¶
Index ¶
- Constants
- Variables
- func Exist(e ...string) bool
- func ExpandEnv(value string) string
- func ExpandEnvMap(m map[string]interface{}) map[string]interface{}
- func GetEnv(e ...string) string
- func GetSystemEnv(e ...string) string
- func InitVersion(name, version, build, commit string)
- func IsDebug() bool
- func IsDev() bool
- func IsProd() bool
- func IsRelease() bool
- func IsSkipErrorFile() bool
- func IsStag() bool
- func IsTest() bool
- func IsTrue(data string) bool
- func IsVersion() bool
- func LoadFile(envFiles ...string) (err error)
- func Log(filter ...interface{})
- func ParseToMap(filter ...interface{}) map[string]string
- func SetDebug() (err error)
- func SetDebugFalse() (err error)
- func SetEnv(e, v string) error
- func SetSkipErrorFile() (err error)
- func SetSystemEnv(e, v string) error
- func SetVersion() (err error)
- func Version()
Constants ¶
View Source
const AppSecretKey = "app_secret"
View Source
const DefaultEnvPrefix = "ggg"
View Source
const DefaultEnvPrefixKey = "env_prefix"
View Source
const EnvPrefixSeparator = "_"
Variables ¶
View Source
var Cfg = struct { Prefix string Service string Version string Env string }{ Prefix: os.Getenv(DefaultEnvPrefixKey), Service: os.Getenv(DefaultEnvPrefixKey), Version: "v0.0.1", 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 ExpandEnv ¶ added in v0.2.8
ExpandEnv 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 ExpandEnvMap ¶ added in v0.2.8
ExpandEnvMap convert all string value with environment variable.
func GetSystemEnv ¶ added in v0.2.25
GetSystemEnv get system environment
func InitVersion ¶ added in v0.2.25
func InitVersion(name, version, build, commit string)
func IsSkipErrorFile ¶ added in v0.2.14
func IsSkipErrorFile() bool
func ParseToMap ¶ added in v0.2.25
Parse 解析envs map[string]string
func SetSystemEnv ¶ added in v0.2.25
SetSystemEnv set system environment variable
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.