about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-30 18:02:40 +0100
committerEmile <hanemile@protonmail.com>2019-10-30 18:02:40 +0100
commit72bd68424b3bc609852bff360d0ec456c0c2fe8f (patch)
treebac33f6d1fd924c78dfda8ade7d8ff92e030ff9f /src
parentc852c772aab04e4b09d99f08cc7968cecd743ee7 (diff)
read data from a wordlist
Diffstat (limited to 'src')
-rw-r--r--src/main.go37
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
 }