package importfunc import ( "bufio" "fmt" "math/rand" "os" ) func GenerateUserIdMap() { list := make([]int64, 0) for i := int64(1000000); i < 100000000; i++ { list = append(list, i) } rand.Shuffle(99000000, func(i, j int) { list[i], list[j] = list[j], list[i] }) j := 1 for i := 0; i < len(list); i += 1000000 { lower := i upper := i + 999999 if upper >= len(list) { upper = len(list) - 1 } WriteAsList(list[lower:upper], j) j++ } } func WriteAsList(list []int64, seq int) { pathurl := fmt.Sprintf("/Users/Caeru/Desktop/file/user_id_map%v.txt", seq) outfile, err := os.OpenFile(pathurl, os.O_WRONLY|os.O_CREATE, 0666) if err != nil { fmt.Printf("Open File Err : %v", err) } defer outfile.Close() writer := bufio.NewWriter(outfile) for i := range list { outfile.WriteString(fmt.Sprintf("%v:%v\n", 1000000*seq+i, list[i])) } writer.Flush() fmt.Printf("%dth file has generated\n", seq) }