mirror of https://github.com/spf13/cast.git
Add ToURL
This commit is contained in:
parent
c01685bb84
commit
ad844c2f56
11
cast.go
11
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)
|
||||
|
|
Loading…
Reference in New Issue