mirror of https://github.com/spf13/cast.git
Update godoc comments
This commit is contained in:
parent
2c719d95d6
commit
e71c5a68f1
40
caste.go
40
caste.go
|
@ -14,7 +14,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToTimeE casts an empty interface to time.Time.
|
// ToTimeE casts an interface to a time.Time type.
|
||||||
func ToTimeE(i interface{}) (tim time.Time, err error) {
|
func ToTimeE(i interface{}) (tim time.Time, err error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func ToTimeE(i interface{}) (tim time.Time, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDurationE casts an empty interface to time.Duration.
|
// ToDurationE casts an interface to a time.Duration type.
|
||||||
func ToDurationE(i interface{}) (d time.Duration, err error) {
|
func ToDurationE(i interface{}) (d time.Duration, err error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func ToDurationE(i interface{}) (d time.Duration, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToBoolE casts an empty interface to a bool.
|
// ToBoolE casts an interface to a bool type.
|
||||||
func ToBoolE(i interface{}) (bool, error) {
|
func ToBoolE(i interface{}) (bool, error) {
|
||||||
|
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
@ -86,7 +86,7 @@ func ToBoolE(i interface{}) (bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToFloat64E casts an empty interface to a float64.
|
// ToFloat64E casts an interface to a float64 type.
|
||||||
func ToFloat64E(i interface{}) (float64, error) {
|
func ToFloat64E(i interface{}) (float64, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ func ToFloat64E(i interface{}) (float64, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToInt64E casts an empty interface to an int64.
|
// ToInt64E casts an interface to an int64 type.
|
||||||
func ToInt64E(i interface{}) (int64, error) {
|
func ToInt64E(i interface{}) (int64, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func ToInt64E(i interface{}) (int64, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToInt32E casts an empty interface to an int32.
|
// ToInt32E casts an interface to an int32 type.
|
||||||
func ToInt32E(i interface{}) (int32, error) {
|
func ToInt32E(i interface{}) (int32, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ func ToInt32E(i interface{}) (int32, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToInt16E casts an empty interface to an int16.
|
// ToInt16E casts an interface to an int16 type.
|
||||||
func ToInt16E(i interface{}) (int16, error) {
|
func ToInt16E(i interface{}) (int16, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ func ToInt16E(i interface{}) (int16, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToInt8E casts an empty interface to an int8.
|
// ToInt8E casts an interface to an int8 type.
|
||||||
func ToInt8E(i interface{}) (int8, error) {
|
func ToInt8E(i interface{}) (int8, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ func ToInt8E(i interface{}) (int8, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToIntE casts an empty interface to an int.
|
// ToIntE casts an interface to an int type.
|
||||||
func ToIntE(i interface{}) (int, error) {
|
func ToIntE(i interface{}) (int, error) {
|
||||||
i = indirect(i)
|
i = indirect(i)
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ func indirectToStringerOrError(a interface{}) interface{} {
|
||||||
return v.Interface()
|
return v.Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringE casts an empty interface to a string.
|
// ToStringE casts an interface to a string type.
|
||||||
func ToStringE(i interface{}) (string, error) {
|
func ToStringE(i interface{}) (string, error) {
|
||||||
i = indirectToStringerOrError(i)
|
i = indirectToStringerOrError(i)
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ func ToStringE(i interface{}) (string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapStringE casts an empty interface to a map[string]string.
|
// ToStringMapStringE casts an interface to a map[string]string type.
|
||||||
func ToStringMapStringE(i interface{}) (map[string]string, error) {
|
func ToStringMapStringE(i interface{}) (map[string]string, error) {
|
||||||
|
|
||||||
var m = map[string]string{}
|
var m = map[string]string{}
|
||||||
|
@ -396,7 +396,7 @@ func ToStringMapStringE(i interface{}) (map[string]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapStringSliceE casts an empty interface to a map[string][]string.
|
// ToStringMapStringSliceE casts an interface to a map[string][]string type.
|
||||||
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
|
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
|
||||||
|
|
||||||
var m = map[string][]string{}
|
var m = map[string][]string{}
|
||||||
|
@ -458,7 +458,7 @@ func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapBoolE casts an empty interface to a map[string]bool.
|
// ToStringMapBoolE casts an interface to a map[string]bool type.
|
||||||
func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
|
func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
|
||||||
|
|
||||||
var m = map[string]bool{}
|
var m = map[string]bool{}
|
||||||
|
@ -481,7 +481,7 @@ func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapE casts an empty interface to a map[string]interface{}.
|
// ToStringMapE casts an interface to a map[string]interface{} type.
|
||||||
func ToStringMapE(i interface{}) (map[string]interface{}, error) {
|
func ToStringMapE(i interface{}) (map[string]interface{}, error) {
|
||||||
|
|
||||||
var m = map[string]interface{}{}
|
var m = map[string]interface{}{}
|
||||||
|
@ -499,7 +499,7 @@ func ToStringMapE(i interface{}) (map[string]interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToSliceE casts an empty interface to a []interface{}.
|
// ToSliceE casts an interface to a []interface{} type.
|
||||||
func ToSliceE(i interface{}) ([]interface{}, error) {
|
func ToSliceE(i interface{}) ([]interface{}, error) {
|
||||||
|
|
||||||
var s []interface{}
|
var s []interface{}
|
||||||
|
@ -520,7 +520,7 @@ func ToSliceE(i interface{}) ([]interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToBoolSliceE casts an empty interface to a []bool.
|
// ToBoolSliceE casts an interface to a []bool type.
|
||||||
func ToBoolSliceE(i interface{}) ([]bool, error) {
|
func ToBoolSliceE(i interface{}) ([]bool, error) {
|
||||||
|
|
||||||
if i == nil {
|
if i == nil {
|
||||||
|
@ -550,7 +550,7 @@ func ToBoolSliceE(i interface{}) ([]bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringSliceE casts an empty interface to a []string.
|
// ToStringSliceE casts an interface to a []string type.
|
||||||
func ToStringSliceE(i interface{}) ([]string, error) {
|
func ToStringSliceE(i interface{}) ([]string, error) {
|
||||||
|
|
||||||
var a []string
|
var a []string
|
||||||
|
@ -576,7 +576,7 @@ func ToStringSliceE(i interface{}) ([]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToIntSliceE casts an empty interface to a []int.
|
// ToIntSliceE casts an interface to a []int type.
|
||||||
func ToIntSliceE(i interface{}) ([]int, error) {
|
func ToIntSliceE(i interface{}) ([]int, error) {
|
||||||
|
|
||||||
if i == nil {
|
if i == nil {
|
||||||
|
@ -606,7 +606,9 @@ func ToIntSliceE(i interface{}) ([]int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StringToDate casts an empty interface to a time.Time.
|
// StringToDate attempts to parse a string into a time.Time type using a
|
||||||
|
// predefined list of formats. If no suitable format is found, an error is
|
||||||
|
// returned.
|
||||||
func StringToDate(s string) (time.Time, error) {
|
func StringToDate(s string) (time.Time, error) {
|
||||||
return parseDateWith(s, []string{
|
return parseDateWith(s, []string{
|
||||||
time.RFC3339,
|
time.RFC3339,
|
||||||
|
|
Loading…
Reference in New Issue