From 723c37b6bd44544e14c42c3fe25a2b147469d0f7 Mon Sep 17 00:00:00 2001 From: shockerli Date: Fri, 9 Sep 2022 22:58:27 +0800 Subject: [PATCH] use `ConvertibleTo` instead of `CanConvert` promise for support go >= 1.13 rv.CanConvert(t) is added in go1.17, but rt.ConvertibleTo(t) is added in go1.1 --- cvte.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cvte.go b/cvte.go index 53387f8..e48a8e4 100644 --- a/cvte.go +++ b/cvte.go @@ -187,7 +187,10 @@ func Indirect(a interface{}) (val interface{}, rv reflect.Value) { } default: // time.Time - if ct := reflect.TypeOf(time.Time{}); rv.CanConvert(ct) { + // promise for support go >= 1.13 + // rv.CanConvert(t) is added in go1.17 + // rt.ConvertibleTo(t) is added in go1.1 + if ct := reflect.TypeOf(time.Time{}); rv.Type().ConvertibleTo(ct) { cv := rv.Convert(ct) return cv.Interface(), cv }