User model/migrations and gorm init

This commit is contained in:
HFO4
2019-11-07 15:56:05 +08:00
parent ece1bca11a
commit aca8bde521
10 changed files with 246 additions and 22 deletions

18
pkg/util/common.go Normal file
View File

@ -0,0 +1,18 @@
package util
import (
"math/rand"
"time"
)
// RandStringRunes 返回随机字符串
func RandStringRunes(n int) string {
var letterRunes = []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
rand.Seed(time.Now().UnixNano())
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}