func (s *Source) Uint32n(n uint32) uint32 {
	if n < 2 {
		return 0
	}
	n--
	mask := ^uint32(0) >> bits.LeadingZeros32(n)
	for {
		u := s.Uint32() & mask
		if u <= n {
			return u
		}
	}
}
Uint32n returns a pseudo-random uint32 in range [0,n) without modulo bias.
package uniformprng
import (
	"encoding/binary"
	"io"
	"math/bits"
	"golang.org/x/crypto/chacha20"
)
type Source struct {
	buf    [8]byte
	cipher *chacha20.Cipher
}
var nonce = make([]byte, chacha20.NonceSize)
func NewSource(seed *[32]byte) *Source {
	cipher, _ := chacha20.NewUnauthenticatedCipher(seed[:], nonce)
	return &Source{cipher: cipher}
}
func RandSource(rand io.Reader) (*Source, error) {
	seed := new([32]byte)
	_, err := io.ReadFull(rand, seed[:])
	if err != nil {
		return nil, err
	}
	return NewSource(seed), nil
}
func (s *Source) Uint32() uint32 {
	b := s.buf[:4]
	for i := range b {
		b[i] = 0
	}
	s.cipher.XORKeyStream(b, b)
	return binary.LittleEndian.Uint32(b)
}