Dmitry Chestnykh
396b73a566
Tweak panic message.
2015-04-04 00:46:40 +02:00
Dmitry Chestnykh
46cf8faafd
Make sure there are at least 2 chars in charset.
2015-04-04 00:45:19 +02:00
Mark Canning
2e215562f6
Correct for bias towards first character in chars
...
Currently the first character in chars has a 1/clen + 1/(maxrb+1) chance of being selected. In the case of StdChars the first character is ~25% more likely to be picked than any other character. This change gives a 1/clen chance to all characters, and is based on math/rand's Int31n(n).
2015-04-03 15:07:17 -07:00
Dmitry Chestnykh
87c54b9ba5
Move allocations later in the function.
2015-01-21 21:40:45 +01:00
Dmitry Chestnykh
69450cc2a9
Simplify: use rand.Read instead of io.ReadFull.
2015-01-21 21:36:57 +01:00
Dmitry Chestnykh
7668ee6861
Fix hanging when requested zero-length string.
...
Add test for NewLen from 0 to 100.
2015-01-21 18:36:13 +01:00
Dmitry Chestnykh
e12eafb5ea
Follow proper documentation style.
2015-01-21 10:10:00 +01:00
Dmitry Chestnykh
b317a711d1
Fix a typo.
2015-01-21 10:05:44 +01:00
Dmitry Chestnykh
131ec1e531
Drop support for Go 1.0 and 1.1.
...
Add Travis testing on 1.4.
2015-01-21 09:48:39 +01:00
Dmitry Chestnykh
76c2ebb03e
Drop MIT license, put code into public domain/CC0.
2014-11-06 23:13:45 +01:00
Dmitry Chestnykh
9eb2cf0919
Simplify.
2014-08-09 17:13:26 +02:00
Dmitry Chestnykh
29a0069dc7
Better var name to avoid confusion with type name.
2014-08-09 17:05:33 +02:00
Dmitry Chestnykh
b09047d1ee
Fix for alphabets of 256 characters.
...
Also, panic if given more.
2014-08-09 17:03:38 +02:00
Oleg Ivanov
1b691aeab2
fixed an endless loop when length of chars is a divisor of 256
2014-08-09 23:08:44 +10:00
Dmitry Chestnykh
6004a1368e
Revert "Remove panic not needed since Go 1.1."
...
This reverts commit 53e2fd7421
.
2013-12-12 18:01:04 +01:00
Dmitry Chestnykh
53e2fd7421
Remove panic not needed since Go 1.1.
2013-09-23 18:48:36 +02:00
Dmitry Chestnykh
97550955b0
Style fix.
2012-01-20 15:24:58 +01:00
Dmitry Chestnykh
00f2f1a9e4
Fix for Go weekly.2012-01-15.
2012-01-16 14:29:26 +01:00
Dmitry Chestnykh
958b406e0e
Avoid modulo bias.
2011-06-06 14:34:01 +02:00
Dmitry Chestnykh
e810e021c7
Use io.ReadFull to read from random source.
2011-04-05 21:52:50 +02:00
Dmitry Chestnykh
6c4e68eee9
Move 0 to position before 1.
2011-04-05 21:48:27 +02:00
Dmitry Chestnykh
7f58d67fe3
Simplify reading from rand.
2011-04-05 20:37:41 +02:00
Dmitry Chestnykh
5abb82120b
Fix docs.
2011-04-05 19:55:23 +02:00
Dmitry Chestnykh
4bfaae0c47
Initial commit.
2011-04-05 17:57:25 +02:00