gut/generics/data.go

14 lines
199 B
Go
Raw Normal View History

2024-02-05 23:04:14 +01:00
package generics
import "encoding/json"
func UnmarshalTo[T any](raw []byte) (*T, error) {
var resp T
err := json.Unmarshal(raw, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}