diff options
author | Emile <hanemile@protonmail.com> | 2019-10-30 18:02:40 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-10-30 18:02:40 +0100 |
commit | 72bd68424b3bc609852bff360d0ec456c0c2fe8f (patch) | |
tree | bac33f6d1fd924c78dfda8ade7d8ff92e030ff9f | |
parent | c852c772aab04e4b09d99f08cc7968cecd743ee7 (diff) |
read data from a wordlist
-rw-r--r-- | src/main.go | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/main.go b/src/main.go index ce29777..3b6ef05 100644 --- a/src/main.go +++ b/src/main.go @@ -1,9 +1,42 @@ package main -import "fmt" +import ( + "bufio" + "fmt" + "log" + "os" +) func main() { + // pase the command line aguments registerFlags() - fmt.Println("vim-go") + // 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 } |