Can gorm register functions that are executed before the query?

problem description

can gorm register functions executed before the query?
I want to record the time spent on the query. It is known that gorm has the function AfterFind, executed after the end of the query to get the time at the end of the query. How can I get the time at the beginning of the query?

Mar.28,2021

  • although I haven't written this kind of code, it can be supported by looking at the documentation, via plugin .
  • something like this: db.Callback (). Query (). Before ("gorm:query"). Register ("my_plugin:before_query", beforeQuery)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-40ad7e7-35fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-40ad7e7-35fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?