| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package main
- import (
- "fmt"
- "math/rand"
- "strings"
- "testing"
- "time"
- )
- func Test_getTime(t *testing.T) {
- now := time.Now().Add(-21 * time.Hour)
- d := ""
- for i := 30; i > 0; i-- {
- num := rand.Intn(24)
- day := now.AddDate(0, 0, -i).Add(time.Duration(num) * time.Hour)
- for j := 0; j < 3; j++ {
- a := rand.Intn(10)
- //fmt.Println(day.Add(time.Duration(j*22)*time.Minute).Format(DateFmtYYYYMMDDHHmmss), a)
- d = fmt.Sprintf("%s (%s,%d)", d, day.Add(time.Duration(j*22)*time.Minute).Format(DateFmtYYYYMMDDHHmmss), a)
- }
- }
- d = fmt.Sprintf("insert into qwert values%s", d)
- fmt.Println(d)
- }
- func Test_getAccount(t *testing.T) {
- s := fmt.Sprintf("iaa%s", GetRandomString(39))
- t.Log(s)
- }
- func GetRandomString(l int) string {
- now := time.Now().Format("060102150405.000")
- nowFmt := strings.Replace(now, ".", "", -1)
- str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- bytes := []byte(str)
- var result []byte
- j := 0
- r := rand.New(rand.NewSource(time.Now().UnixNano() + int64(rand.Intn(100))))
- for i := 0; i < l; i++ {
- if i%2 != 0 && j < len(nowFmt) {
- result = append(result, nowFmt[j])
- j++
- } else {
- result = append(result, bytes[r.Intn(len(bytes))])
- }
- }
- return string(result)
- }
|