-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: please consider another lib than https://github.com/spf13/cast #76
Comments
Hello, thanks to have opening an issue. I have try with
Can you check your code and give me the part impacted |
I reported the issue by reading the documentation The problem I found was here https://github.com/spf13/cast/blob/487df0093482b2ca1c00cb3b92e30899c37038a1/caste.go#L287 A uint can overflow int64 you can take 9223372036854775807 that is the max and add 1, so 9223372036854775808 using toInt or toInt64 on it, should cause errors, but it doesn't. I reported by using the example of a negative number because it was simpler to explain, but I wrongly assumed negative number could cause a problem too. But please note, I might be wrong again 🤕 |
@ccoVeille Hi 👋 After some investigation, I believe it would be better to incorporate the casting directly into sprout itself to only have what we want and how we want it ! |
I'm fine with this. You can copy paste my code its on MIT license. |
Can I let you manipulate and incorporate your code ? Feel free to add an header of the
Thanks 🙏 |
Can you remind me why you don't want to use my lib? You are already using other libs
|
Hi, the idea arent to "don't use your lib", is to limit and reduce the number of dependencies. To eliminate this, there are two possible solutions:
|
Thanks for replying me. It's clearer. I had planed and it's almost ready to cast as bool and string (for string, I will have to check what spf13/cast does) I will also check what spf13/cast does for duration. It's unclear to me |
@ccoVeille, have you had a chance to look into adding the missing cast method to safe-cast? |
Not yet, I worked on my own roadmap and added the things I needed. I released v1.5.0 yesterday. My lib is now stable. Please open an issue on my project with the exact need. I don't know yet if I will support everything. My lib is focused on number overflows. |
You have a proposal, explain it!
This lib is still maintained but the way it converts integer is very strange
https://github.com/spf13/cast
Describe the solution you'd like
a conversion of -1 | toUint should lead to error
Additional context
Please take a look at https://github.com/ccoVeille/go-safecast
I'm not suggesting to use my lib, but you might see some other examples.
Of course, I would be honored if you consider my lib
Code of Conduct
The text was updated successfully, but these errors were encountered: