Browse Source

Add ToURL

pull/83/head
andrewheberle GitHub 4 years ago
parent
commit
ad844c2f56
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      cast.go

+ 10
- 1
cast.go View File

@@ -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…
Cancel
Save