From 8ab370f705b4475e9f18e80152a01a9944f2bdb5 Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 12 Feb 2024 07:00:25 +0100 Subject: [PATCH] Cleaning up code and adding hiddenChar viewer --- golangr/file-reader/go.mod | 2 +- golangr/file-reader/main.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/golangr/file-reader/go.mod b/golangr/file-reader/go.mod index 5b20b70..7713c7f 100644 --- a/golangr/file-reader/go.mod +++ b/golangr/file-reader/go.mod @@ -1,3 +1,3 @@ module file-reader -go 1.21.6 +go 1.22 diff --git a/golangr/file-reader/main.go b/golangr/file-reader/main.go index 1ca5f9c..1e00400 100644 --- a/golangr/file-reader/main.go +++ b/golangr/file-reader/main.go @@ -26,6 +26,9 @@ var names = []string{} var err error var guess string var guessLetter rune +var filePath string = os.Args[1] +var randWord string = getWord(filePath) +var hiddenChars []string func scanLine() (line string) { in := bufio.NewReader(os.Stdin) @@ -41,6 +44,10 @@ func main() { os.Exit(1) } + for range randWord { + hiddenChars = append(hiddenChars, "_") + } + for { clear() @@ -79,12 +86,13 @@ func gameStatus() { clear() fmt.Println("Player:", player.name) fmt.Println("Lives:", player.lives) + fmt.Println("Word:", hiddenChars) } func game() { clear() - filePath := os.Args[1] - randWord := getWord(filePath) + //filePath := os.Args[1] + //randWord := getWord(filePath) for { gameStatus() if player.lives < 0 {