fast-replace/go-fast-replace/cmd/pairs/main.go

34 lines
526 B
Go
Raw Normal View History

2023-12-30 21:35:09 +00:00
package main
import (
"fmt"
"log"
"os"
"internal/pairs"
)
func main() {
fmt.Println("Creating pairs...")
f, err := os.OpenFile("./csv/pairs.csv", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
if err != nil {
log.Fatal(err)
}
defer f.Close()
2023-12-31 17:18:29 +00:00
var total int = 1000
if len(os.Args) > 1 {
i, err := strconv.Atoi(os.Args[1])
if err != nil {
log.Fatal(err)
}
total = i
}
lines := pairs.MakePairs(total)
2023-12-30 21:35:09 +00:00
// Write to file
for _, line := range lines {
f.WriteString(line + "\n")
}
}