What brings the v2 ?
- better performance (6bc8c533e43bf87c5476ce0b7752b2abe3a431ed)
- Parse function for handling string (c6de71ac2205f49539a3a230bb665a5f340fda8c)
- support of uintptr (696623ed6fa9b8acab183c0d4a02320eeac460ef)
- Ability to Parse with a dedicated base: see Parse examples and strconv.ParseInt for more information (c6de71ac2205f49539a3a230bb665a5f340fda8c)
- Add WithDecimalLossReport option for Convert to report when a float to integer could lead to decimal lost (748182bba556f3f2550e1029e37ccf88b837d41c)
Fixed
-
float overflow handling with parse float from string
Previously, it returned an ErrStringConversion error while it's an overflow. Now it returns the proper overflow error.
BREAKING CHANGES
- package no longer supports converting from bool
true/false are no longer converted to 1/0 These values cannot overflow, this was an error.
- Convert no longer supports converting from string
You can now use Parse function
- string to number conversion no longer uses base 0 (auto-detect in Go strconv library)
Use Parse function with proper base instead
This solves issue with 07 being parsed as 7, and 08 being reported as an invalid octal
- Convert no longer returns 0 when conversion fails (e6c51375332cff1e4006914da8e3eec2abd69173)
It now returns the invalid converted value with the error
- Removed Input type (Input=string|bool|Number)
This type was used by Convert function to represent input value. Now Convert function uses Number type directly.
This also drastically improves performance as it removes the type assertion checks.
All of these was introduced with https://github.com/ccoVeille/go-safecast/pull/120
Minor
- build(deps): bump crate-ci/typos from 1.38.1 to 1.39.0 in the all group by @dependabot[bot] in https://github.com/ccoVeille/go-safecast/pull/127
Full Changelog: https://github.com/ccoVeille/go-safecast/compare/v1.8.1...v2.0.0