mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-10-04 12:31:32 +00:00
refactor entire backend
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package stringutil provides string utility functions.
|
||||
package stringutil
|
||||
|
||||
import (
|
||||
@@ -6,11 +7,9 @@ import (
|
||||
|
||||
// RandomAlNumString generates a random alphanumeric string of length n.
|
||||
func RandomAlNumString(n int) (string, error) {
|
||||
const (
|
||||
dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
)
|
||||
const dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
||||
var bytes = make([]byte, n)
|
||||
bytes := make([]byte, n)
|
||||
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
return "", err
|
||||
@@ -23,13 +22,11 @@ func RandomAlNumString(n int) (string, error) {
|
||||
return string(bytes), nil
|
||||
}
|
||||
|
||||
// RandomNumericString generates a random digit numeric string of length n.
|
||||
// RandomNumericString generates a random numeric string of length n.
|
||||
func RandomNumericString(n int) (string, error) {
|
||||
const (
|
||||
dictionary = "0123456789"
|
||||
)
|
||||
const dictionary = "0123456789"
|
||||
|
||||
var bytes = make([]byte, n)
|
||||
bytes := make([]byte, n)
|
||||
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user