gut/generics/data.go
2024-02-05 23:04:14 +01:00

14 lines
199 B
Go

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
}