diff --git a/cast.go b/cast.go index 9fba638..c56b753 100644 --- a/cast.go +++ b/cast.go @@ -6,7 +6,10 @@ // Package cast provides easy and safe casting in Go. package cast -import "time" +import ( + "net/url" + "time" +) // ToBool casts an interface to a bool type. func ToBool(i interface{}) bool { @@ -20,6 +23,12 @@ func ToTime(i interface{}) time.Time { return v } +// ToURL casts an interface to a *url.URL type. +func ToURL(i interface{}) *url.URL { + v, _ := ToURLE(i) + return v +} + // ToDuration casts an interface to a time.Duration type. func ToDuration(i interface{}) time.Duration { v, _ := ToDurationE(i)