2014-04-05 13:21:52 +08:00
|
|
|
// Copyright © 2014 Steve Francia <spf@spf13.com>.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by an MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cast
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
func ToBool(i interface{}) bool {
|
|
|
|
v, _ := ToBoolE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToTime(i interface{}) time.Time {
|
|
|
|
v, _ := ToTimeE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2015-02-19 10:56:24 +08:00
|
|
|
func ToDuration(i interface{}) time.Duration {
|
|
|
|
v, _ := ToDurationE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2014-04-05 13:21:52 +08:00
|
|
|
func ToFloat64(i interface{}) float64 {
|
|
|
|
v, _ := ToFloat64E(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToInt(i interface{}) int {
|
|
|
|
v, _ := ToIntE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToString(i interface{}) string {
|
|
|
|
v, _ := ToStringE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToStringMapString(i interface{}) map[string]string {
|
|
|
|
v, _ := ToStringMapStringE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2014-11-06 18:32:02 +08:00
|
|
|
func ToStringMapBool(i interface{}) map[string]bool {
|
|
|
|
v, _ := ToStringMapBoolE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2014-04-05 13:21:52 +08:00
|
|
|
func ToStringMap(i interface{}) map[string]interface{} {
|
|
|
|
v, _ := ToStringMapE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2014-04-27 06:56:25 +08:00
|
|
|
func ToSlice(i interface{}) []interface{} {
|
|
|
|
v, _ := ToSliceE(i)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2014-04-05 13:21:52 +08:00
|
|
|
func ToStringSlice(i interface{}) []string {
|
|
|
|
v, _ := ToStringSliceE(i)
|
|
|
|
return v
|
|
|
|
}
|
2015-02-24 18:58:16 +08:00
|
|
|
|
|
|
|
func ToIntSlice(i interface{}) []int {
|
|
|
|
v, _ := ToIntSliceE(i)
|
|
|
|
return v
|
|
|
|
}
|