Skip to content

Commit

Permalink
use ConvertibleTo instead of CanConvert
Browse files Browse the repository at this point in the history
promise for support go >= 1.13
rv.CanConvert(t) is added in go1.17, but rt.ConvertibleTo(t) is added in go1.1
  • Loading branch information
shockerli committed Sep 9, 2022
1 parent b09b389 commit 723c37b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cvte.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

1 comment on commit 723c37b

@vercel
Copy link

@vercel vercel bot commented on 723c37b Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.