mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-09 15:55:47 +08:00
refactor: 后端包结构重构、去除无用的文件
This commit is contained in:
21
server/pkg/utils/assert/assert.go
Normal file
21
server/pkg/utils/assert/assert.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package assert
|
||||
|
||||
import "fmt"
|
||||
|
||||
// 断言条件为真,不满足的panic
|
||||
func IsTrue(condition bool, panicMsg string, params ...interface{}) {
|
||||
if !condition {
|
||||
if len(params) != 0 {
|
||||
panic(fmt.Sprintf(panicMsg, params...))
|
||||
}
|
||||
panic(panicMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func State(condition bool, panicMsg string, params ...interface{}) {
|
||||
IsTrue(condition, panicMsg, params...)
|
||||
}
|
||||
|
||||
func NotEmpty(str string, panicMsg string, params ...interface{}) {
|
||||
IsTrue(str != "", panicMsg, params...)
|
||||
}
|
||||
Reference in New Issue
Block a user