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 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)
Constants ¶
View Source
const ( // EnvPrefixSeparator 项目环境变量分隔符 EnvPrefixSeparator = "_" // DefaultEnvPrefix 项目默认环境变量前缀 DefaultEnvPrefix = "ggg" // DefaultEnvPrefixKey 项目默认环境变量名字 DefaultEnvPrefixKey = "env_prefix" // AppSecretKey 项目应用密码名字 AppSecretKey = "app_secret" )
Variables ¶
View Source
var Cfg = struct { Prefix string Service string Version string Env string Debug bool Home string LogLevel string }{ Prefix: trim(os.Getenv(DefaultEnvPrefixKey)), Service: trim(os.Getenv(DefaultEnvPrefixKey)), Version: "v0.0.1", Env: RunMode.Dev, Debug: true, Home: os.ExpandEnv("$PWD"), LogLevel: "debug", }
Cfg 默认配置
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", }
RunMode 项目运行模式
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 IsSkipErrorFile ¶ added in v0.2.14
func IsSkipErrorFile() bool
IsSkipErrorFile skip xerror file
func ParseToMap ¶ added in v0.2.25
ParseToMap 解析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.