cast
cast copied to clipboard
safe and easy casting from one type to another in Go
#211 The ToUint64E function was fixed to correctly handle strings that overflow the maximum value of int64. Previously, the function incorrectly returned zero for these input values because it was...
Wondering if empty string shouldn't be treated similar to nil?
I suggest adding a default value to all 'To___' methods. Before: ``` // ToBool casts an interface to a bool type. func ToBool(i interface{}) bool { v, _ := ToBoolE(i)...
cast max uint32 string to uint32: cast.ToUint32E("4294967295") returns 0 and err: unable to cast "4294967295" of type string to uint32 cast max uint64 string to uint64: cast.ToUint64E("18446744073709551615") returns 0 and...
I encountered an unexpected behavior when converting a string to a `float64` and then performing a multiplication operation. The result seems to have a precision issue. **Steps to Reproduce:** 1....
#220 This PR addresses an issue where cast.ToInt returned 0 when converting string values with leading zeros, such as "08", instead of the expected integer. The issue has been identified...
run cast.ToInt("08") return 0 cast.ToInt("07") return 7 ? my go version is go1.22.0
Hi! In this PR, I added support to convert string slice to string using `strings.Join(s, ",")`. I was experimenting yesterday with some code based on `spf13/viper` and was surprised to...
This code: ```go package main import "time" import "github.com/spf13/cast" func main() { var now *time.Time var s string var err error s, err= cast.ToStringE(now) println(s, err) } ``` Produces a...
I used `cast.ToTime ()` to convert `'2006-01-02 15:04:05'` format time string, and then compared with `time.Now()`, there is a problem. I would like to ask why `cast.ToTime()` uses `UTC` instead...