update events

This commit is contained in:
andrusyakka
2023-07-17 14:12:32 +03:00
parent 454c9bc82e
commit 1aa6b6c87e
3 changed files with 21 additions and 11 deletions

View 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
}