github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/gorm/gormDBHaving/install.go (about) 1 package gormDBHaving 2 3 import ( 4 "fmt" 5 "github.com/HXSecurity/DongTai-agent-go/model" 6 "github.com/brahma-adshonor/gohook" 7 "gorm.io/gorm" 8 ) 9 10 func init() { 11 model.HookMap["gormDBHaving"] = new(GormDBHaving) 12 } 13 14 type GormDBHaving struct { 15 } 16 17 func (h *GormDBHaving) Hook() { 18 db := &gorm.DB{} 19 err := gohook.HookMethod(db, "Having", Having, HavingT) 20 if err != nil { 21 fmt.Println(err, "gormHaving") 22 } else { 23 fmt.Println("gormHavingr") 24 } 25 } 26 27 func (h *GormDBHaving) UnHook() { 28 db := &gorm.DB{} 29 gohook.UnHookMethod(db, "Having") 30 }