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