From ad844c2f56c5c9d956c289ac7c2759ec6f8a81c1 Mon Sep 17 00:00:00 2001 From: andrewheberle Date: Mon, 24 Jun 2019 09:57:59 +0800 Subject: [PATCH] Add ToURL --- cast.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)