Update .editorconfig
[fbfp.git] / misc.go
blob172ed90c43a5199693408cd23386aaf3aae37645
1 package main
3 import (
4 "crypto/rand"
5 "encoding/base64"
8 func e(e error) {
9 if e != nil {
10 panic(e)
15 * Generate a random url-safe string.
16 * Note that the "len" parameter specifies the number of bytes taken from the
17 * random source divided by three and does NOT represent the length of the
18 * encoded string.
20 func random(len int) string {
21 r := make([]byte, 3*len)
22 rand.Read(r)
23 return base64.RawURLEncoding.EncodeToString(r)