From 887e0556bfd74fa2252d77480d0cb00ebf07ea7b Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 13 Feb 2024 07:37:54 +0000 Subject: [PATCH] No longer rendering spaces as secret characters --- golangr/file-reader/main.go | 9 ++++++--- golangr/file-reader/words.txt | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/golangr/file-reader/main.go b/golangr/file-reader/main.go index 6041958..44f4daf 100644 --- a/golangr/file-reader/main.go +++ b/golangr/file-reader/main.go @@ -36,9 +36,12 @@ func main() { filePath = os.Args[1] randWord = getWord(filePath) - for range randWord { - // TODO: Detect spaces in string and don't set them to "_" - hiddenChars = append(hiddenChars, "_") + for _, v := range randWord { + if string(v) == " " { + hiddenChars = append(hiddenChars, " ") + } else { + hiddenChars = append(hiddenChars, "_") + } } for _, v := range randWord { revealedChars = append(revealedChars, string(v)) diff --git a/golangr/file-reader/words.txt b/golangr/file-reader/words.txt index b0bf0b3..c01b73e 100644 --- a/golangr/file-reader/words.txt +++ b/golangr/file-reader/words.txt @@ -1,5 +1,6 @@ fantastic achieve +this is a spaced sentence security tool cathedral