cast
cast copied to clipboard
safe and easy casting from one type to another in Go
a := []string{"01", "02", "03", "04", "05", "06", "07", "08", "09"} for _, v := range a { fmt.Println(cast.ToInt64(v)) } // output 1 2 3 4 5 6 7 0...
use **cast.toTime(timeStr).Unix()** will get +8 Hours Unix TIme,different with time.ParseInLocation.Unix(), in Beijing Area. How To Resolve?
I would like to have a method for casting from `i interface{}` to `uuid.UUID`? SEE: https://www.uuidtools.com/uuid-versions-explained
I was hoping that `ToStringSlice` would support turning a slice of ints into a slice of strings. Am I wrong in that assumption? The following fails: ```go nums := []int{1,2,3,4,5}...
**Add convert any types code to ToStringMapE** This PR will add a convert code to ``ToStringMapE`` function for handle unexpected type such as any struct type - [x] Add convert...
To make it easier to use [Go1.13's `errors.Is` and `errors.As`](https://blog.golang.org/go1.13-errors), it'd be great if the `To___E` functions wrap a common "cast error" so that transitive callers to these functions can...
Fixes issue #74 It fixes the expected behavior of cast.ToInt() with a string prefixed with "0". Before this fix `cast.ToInt("01234")` results into `668` instead of `1234`. Now it converts strings...
Adds ToURL and ToURLE functions to cast an interface to a "*url.URL" type