diff --git a/golangr/file-reader/file-reader b/golangr/file-reader/file-reader new file mode 100755 index 0000000..209b7c3 Binary files /dev/null and b/golangr/file-reader/file-reader differ diff --git a/golangr/file-reader/main.go b/golangr/file-reader/main.go index 1e00400..78ac17e 100644 --- a/golangr/file-reader/main.go +++ b/golangr/file-reader/main.go @@ -8,8 +8,6 @@ import ( "strconv" "strings" "time" - //"time" - //"strconv" ) type PlayerStats struct { @@ -26,8 +24,8 @@ var names = []string{} var err error var guess string var guessLetter rune -var filePath string = os.Args[1] -var randWord string = getWord(filePath) +var filePath string +var randWord string var hiddenChars []string func scanLine() (line string) { @@ -43,6 +41,8 @@ func main() { fmt.Println("Usage: ./file-reader names.txt") os.Exit(1) } + filePath = os.Args[1] + randWord = getWord(filePath) for range randWord { hiddenChars = append(hiddenChars, "_") @@ -91,8 +91,6 @@ func gameStatus() { func game() { clear() - //filePath := os.Args[1] - //randWord := getWord(filePath) for { gameStatus() if player.lives < 0 {