about summary refs log tree commit diff
path: root/src/main.go
blob: 3b6ef0566f68133edf7448ac56d5b23322cd6364 (plain)
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
39
40
41
42
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

func main() {
	// pase the command line aguments
	registerFlags()

	// read the wordlist
	lines, err := readWordlist(wordlist)
	if err != nil {
		log.Println(err)
	}

	for i, line := range lines {
		fmt.Printf("%d %s\n", i, string(line))
	}
}

func readWordlist(wordlistPath string) ([]string, error) {
	file, err := os.Open(wordlistPath)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	scanner.Split(bufio.ScanLines)

	var lines []string

	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}

	return lines, nil
}