Skip to content

Instantly share code, notes, and snippets.

View donnol's full-sized avatar
💭
Boring

donnol donnol

💭
Boring
View GitHub Profile
@donnol
donnol / proxy_test.go
Created May 10, 2022 08:03
Go proxy between layer
// === Around ===
type Ctx struct {
Uniq string // 包名+接口名+方法名
}
type CtxFunc func(ctx Ctx, method any, args []any) (res []any)
var (
customCtxMap = make(map[string]CtxFunc)
)
@donnol
donnol / iszero.go
Created September 11, 2021 11:24
Go IsZero func
// IsZeror 可自定义类型实现IsZero方法,用于自定义空值检查,比如要对字符串做TrimSpace操作后再与空值比较
type IsZeror interface {
IsZero() bool
}
// IsZero 判断值v是否为所属类型的零值
// 即使是int和int64两个case也不能合并
func IsZero(v interface{}) bool {
switch vv := v.(type) {