Documentation
¶
Index ¶
- Constants
- Variables
- func App() string
- func EnableDebug()
- func Env() string
- func IsCIEnv() bool
- func IsDebug() bool
- func IsDevelopEnv() bool
- func IsProductionEnv() bool
- func IsTestingEnv() bool
- func PrintBuildInfo()
- func SafeGo(fn func(), errHandler func(error))
- func SafeGoWithError(fn func() error, errHandler func(error))
- func SafeRun(fn func()) (err error)
- func SafeRunWithError(fn func() error) (err error)
Constants ¶
View Source
const ( EnvProd = "production" // 生产环境 EnvTesting = "testing" // 测试环境 EnvCI = "test_ci" // CI 环境 EnvDevelop = "develop" // 开发环境 NonSandboxDeployID = "0" // 非联调环境部署Id )
Variables ¶
Functions ¶
func EnableDebug ¶
func EnableDebug()
func IsDevelopEnv ¶
func IsDevelopEnv() bool
func IsProductionEnv ¶
func IsProductionEnv() bool
func IsTestingEnv ¶
func IsTestingEnv() bool
func PrintBuildInfo ¶
func PrintBuildInfo()
Print your build info
Need add build flags
go build -ldflags " -X 'github.com/everywan/commons/utils.AppName=${APP_NAME}' \ -X 'github.com/everywan/commons/utils.AppVersion=${APP_VERSION}' \ -X 'github.com/everywan/commons/utils.BuildVersion=${BUILD_VERSION}' \ -X 'github.com/everywan/commons/utils.BuildTime=${BUILD_TIME}' \ -X 'github.com/everywan/commons/utils.GitRevision=${GIT_REVISION}' \ -X 'github.com/everywan/commons/utils.GitBranch=${GIT_BRANCH}' \ -X 'github.com/everywan/commons/utils.GoVersion=${GO_VERSION}' \ -s -w " -mod vendor -v -o $(NAME) ${MAIN}
func SafeGo ¶
func SafeGo(fn func(), errHandler func(error))
SafeGo async run a func. If the func panics, the panic value will be handle by errHandler.
func SafeGoWithError ¶
SafeGoWithError async run a func with error. If the func panics, the panic value will be handle by errHandler.
func SafeRun ¶
func SafeRun(fn func()) (err error)
SafeRun sync run a func. If the func panics, the panic value is returned as an error.
func SafeRunWithError ¶
SafeRun sync run a func with error. If the func panics, the panic value is returned as an error.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.