mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 16:30:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			452 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			452 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package assert
 | 
						||
 | 
						||
import "fmt"
 | 
						||
 | 
						||
// 断言条件为真,不满足的panic
 | 
						||
func IsTrue(condition bool, panicMsg string, params ...any) {
 | 
						||
	if !condition {
 | 
						||
		if len(params) != 0 {
 | 
						||
			panic(fmt.Sprintf(panicMsg, params...))
 | 
						||
		}
 | 
						||
		panic(panicMsg)
 | 
						||
	}
 | 
						||
}
 | 
						||
 | 
						||
func State(condition bool, panicMsg string, params ...any) {
 | 
						||
	IsTrue(condition, panicMsg, params...)
 | 
						||
}
 | 
						||
 | 
						||
func NotEmpty(str string, panicMsg string, params ...any) {
 | 
						||
	IsTrue(str != "", panicMsg, params...)
 | 
						||
}
 |