Hi, thanks for providing lo!
The RandomString functions exits with panic: runtime error: integer divide by zero if the charset only has a single element.
randStr := lo.RandomString(10, []rune{65})
This happens in this line and the divisor is calculated on this line. The reason for the zero value is that nearestPowerOfTwo returns 1 and log(1) is zero.
This may be an edge case (we use it in tests to force a predictable value) but still should be handled somehow.
Thanks!
Hi, thanks for providing lo!
The
RandomStringfunctions exits withpanic: runtime error: integer divide by zeroif the charset only has a single element.This happens in this line and the divisor is calculated on this line. The reason for the zero value is that
nearestPowerOfTworeturns 1 and log(1) is zero.This may be an edge case (we use it in tests to force a predictable value) but still should be handled somehow.
Thanks!