Input normalization transforms incoming values into a consistent representation before validation or further processing. For a word game, converting guesses to uppercase lets the program handle mixed-case input uniformly. section 5.1.3
Normalize a word-game guess
Replace direct rune conversion such as `[]rune(string(suggestion))` with `splitToUppercaseCharacters(suggestion)`. The function applies `strings.ToUpper` and returns the result as a rune slice, turning `Go` or `go` into `GO` before validation.
Listing 5.17 game.go: Split characters
// splitToUppercaseCharacters is a naive implementation to turn a string
// into a list of characters.
func splitToUppercaseCharacters(input string) []rune {
return []rune(strings.ToUpper(input))
}
Inspect the small Go helper that centralizes uppercase conversion and rune splitting, making later support for other writing systems easier to add. section 5.1.3
Test normalization and the validation boundary separately:
- Add a focused test that verifies mixed-case input becomes the expected uppercase rune sequence. section 5.1.3
