Move remaining writeas/nerds/store funcs to web-core
Finishes the work started in #8.
This commit is contained in:
+13
-1
@@ -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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user