Move remaining writeas/nerds/store funcs to web-core

Finishes the work started in #8.
This commit is contained in:
Matt Baer
2021-03-30 12:44:22 -04:00
parent 8dbd86535d
commit 95a3a717ed
+13 -1
View File
@@ -1,8 +1,8 @@
package id package id
import ( import (
"fmt"
"crypto/rand" "crypto/rand"
"fmt"
) )
// GenerateRandomString creates a random string of characters of the given // GenerateRandomString creates a random string of characters of the given
@@ -24,3 +24,15 @@ func GenerateRandomString(dictionary string, l int) string {
func GenSafeUniqueSlug(slug string) string { func GenSafeUniqueSlug(slug string) string {
return fmt.Sprintf("%s-%s", slug, GenerateRandomString("0123456789bcdfghjklmnpqrstvwxyz", 4)) return fmt.Sprintf("%s-%s", slug, GenerateRandomString("0123456789bcdfghjklmnpqrstvwxyz", 4))
} }
// Generate62RandomString creates a random string with the given length
// consisting of characters in [A-Za-z0-9].
func Generate62RandomString(l int) string {
return GenerateRandomString("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", l)
}
// GenerateFriendlyRandomString creates a random string of characters with the
// given length consisting of characters in [a-z0-9].
func GenerateFriendlyRandomString(l int) string {
return GenerateRandomString("0123456789abcdefghijklmnopqrstuvwxyz", l)
}