19 lines
263 B
Go
19 lines
263 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
func Convert[T any, V any](obj T, result *V) error {
|
|
messageBytes, err := json.Marshal(obj)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(messageBytes, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|