Last active
October 13, 2021 12:03
-
-
Save jiaqi-yin/8485bcb41253a779fe684cd17b89af07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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