Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func String ¶ added in v1.49.26
String returns exactly n characters drawn uniformly from alphabet.
It is the primitive to reach for when the output has a shape someone will read back or type in — a referral code, a coupon — rather than base64 with the awkward characters filtered out afterwards. Filtering is what made referral codes "eight characters, unless the draw happened to contain four of '-' and '_', in which case seven or fewer".
Rejection sampling keeps the draw uniform. Folding a byte modulo the alphabet size would favour its first 256 % len(alphabet) characters, and a code with a lopsided alphabet is a code with less entropy than its length advertises.
Types ¶
This section is empty.