update events
This commit is contained in:
16
pkg/utils/type-coverter.go
Normal file
16
pkg/utils/type-coverter.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func TypeConverter[R any](data any) (*R, error) {
|
||||
var result R
|
||||
b, err := json.Marshal(&data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(b, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, err
|
||||
}
|
||||
Reference in New Issue
Block a user