利用random给数据主键生成唯一ID
// 生成: 时间戳 + 设置前缀 + 随即字符串
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
func RandomString(pixff string, strlen int) string {
rand.Seed(time.Now().UTC().UnixNano())
result := make([]byte, strlen)
for i := 0; i < strlen; i++ {
result[i] = alphanum[rand.Intn(len(alphanum))]
}
return time.Now().Format("20151212010203") + "-" + pixff + "-" + string(result)
}