-
Notifications
You must be signed in to change notification settings - Fork 0
/
ua.go
38 lines (31 loc) · 806 Bytes
/
ua.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"os"
"strconv"
"github.com/brianvoe/gofakeit/v6"
"strings"
"io/ioutil"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage: go run ua.go [save file] [amount]")
return
}
saveFile := os.Args[1]
amount, err := strconv.Atoi(os.Args[2])
if err != nil {
fmt.Println("Please provide a valid number for amount")
return
}
var userAgents []string
for i := 0; i < amount; i++ {
userAgents = append(userAgents, gofakeit.UserAgent())
}
err = ioutil.WriteFile(saveFile, []byte(strings.Join(userAgents, "\n")), 0644)
if err != nil {
fmt.Println("Error writing to file:", err)
return
}
fmt.Printf("%d user agents saved to %s\n", amount, saveFile)
}