github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/gorm/gormDBPluck/install.go (about)

     1  package gormDBPluck
     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["gormDBPluck"] = new(GormDBPluck)
    12  }
    13  
    14  type GormDBPluck struct {
    15  }
    16  
    17  func (h *GormDBPluck) Hook() {
    18  	db := &gorm.DB{}
    19  	err := gohook.HookMethod(db, "Pluck", Pluck, PluckT)
    20  	if err != nil {
    21  		fmt.Println(err, "GormDBPluck")
    22  	} else {
    23  		fmt.Println("GormDBPluck")
    24  	}
    25  }
    26  
    27  func (h *GormDBPluck) UnHook() {
    28  	db := &gorm.DB{}
    29  	gohook.UnHookMethod(db, "Pluck")
    30  }