Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IfErrPanic ¶
func IfErrPanic(err error)
func Ternary ¶
Ternary 可以实现简单的条件判断功能。go原生不支持三元运算符,本函数可以提供类似的使用方式 Ternary[T any](b bool, v1 T, v2 T) T @param b bool 条件:true时返回v1;false时返回v2 @param v1 T 值1,条件为true时作为返回值 @param v2 T 值2,条件为false时作为返回值
func TryCatch ¶
func TryCatch(tryFn func(), catchFn func(err Exception))
TryCatch 捕捉panic错误,防止服务退出,并提供error错误。go原生不支持try-catch语法,对于习惯try-catch的开发者来说很难受,虽然这是一种不好的习惯 TryCatch(tryFn func(), catchFn func(err bzcode.Exception)) @param tryFn func() 代码容器 @param catchFn func(err bzcode.Exception) 代码容器中发生panic错误后返回的error message
Types ¶
Click to show internal directories.
Click to hide internal directories.