Skip to content

Instantly share code, notes, and snippets.

@jiaqi-yin
Last active October 13, 2021 12:03
Show Gist options
  • Save jiaqi-yin/8485bcb41253a779fe684cd17b89af07 to your computer and use it in GitHub Desktop.
Save jiaqi-yin/8485bcb41253a779fe684cd17b89af07 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/bxcodec/faker/v3"
)
func main() {
file, err := os.OpenFile("/tmp/file.log", os.O_WRONLY|os.O_APPEND, os.ModePerm)
if err != nil {
panic(fmt.Sprintf("Open file err: %s", err.Error()))
}
defer file.Close()
for i := 0; i < 10000; i++ {
for i := 0; i < 100; i++ {
line := fmt.Sprintf("%s,%s,%s\n", faker.UUIDDigit(), faker.FirstName(), faker.LastName())
_, err := file.Write([]byte(line))
if err != nil {
log.Println("writeToFile error:", err)
}
}
time.Sleep(200 * time.Millisecond)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment