Closed tonybase closed 3 years ago
Fixes convert to protobuf known types failure.
enc := schema.NewEncoder() enc.SetAliasTag("json") enc.RegisterEncoder(&durationpb.Duration{}, func(v reflect.Value) string { return "100s" }) dec := schema.NewDecoder() dec.SetAliasTag("json") dec.RegisterConverter(&durationpb.Duration{}, func(v string) reflect.Value { d, err := time.ParseDuration(v) if err != nil { return reflect.Value{} } return reflect.ValueOf(durationpb.New(d)) })
References: https://github.com/golang/go/blob/master/src/encoding/json/encode.go#L1244 https://github.com/go-kratos/kratos/pull/1152
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
Fixes convert to protobuf known types failure.
References: https://github.com/golang/go/blob/master/src/encoding/json/encode.go#L1244 https://github.com/go-kratos/kratos/pull/1152