cast
cast copied to clipboard
Added ToBase<Int|Uint|etc>() functions for ToBaseInt('08', 10) => 8 (Fixes #232)
This PR fixes #232 by allowing the user to cast as a Base derived value from the interface.
Methods added:
# Public Methods inside `cast.go`
ToBaseInt64(input interface, base int)
ToBaseInt32(input interface, base int)
ToBaseInt16(input interface, base int)
ToBaseInt8(input interface, base int)
ToBaseInt(input interface, base int)
ToBaseUint(input interface, base int)
ToBaseUint64(input interface, base int)
ToBaseUint32(input interface, base int)
ToBaseUint16(input interface, base int)
ToBaseUint8(input interface, base int)
# Internal Methods inside `caste.go`
ToUint8EB(input interface, base int)
ToUint16EB(input interface, base int)
ToUint32EB(input interface, base int)
ToUint64EB(input interface, base int)
ToUintEB(input interface, base int)
ToIntEB(input interface, base int)
ToInt8EB(input interface, base int)
ToInt16EB(input interface, base int)
ToInt32EB(input interface, base int)
ToInt64EB(input interface, base int)
Quite literally, this PR duplicates a TON of code (lovely) and provides you the ability to specify the 2nd argument on the strconv.Parse<Int|Uint>(num, base, bits) functions in caste.go.
Thanks @andreimerlescu !
Let me see if we can reduce the code duplication.
Question: Why don't ToXYZEB functions follow the ToBaseXYZ pattern (ToBaseXYZE)?
#250 might help reducing the amount of code duplications.