mirror of
https://github.com/wonli/aqi.git
synced 2024-06-28 09:57:05 +08:00
17 lines
222 B
Go
17 lines
222 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
)
|
|
|
|
func GetRandomString(n int) string {
|
|
randBytes := make([]byte, n/2)
|
|
_, err := rand.Read(randBytes)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
return fmt.Sprintf("%x", randBytes)
|
|
}
|