// readWordListInternal exists for testing purposes.
readWordListInternal exists for testing purposes.
// readWordListInternal exists for testing purposes .
func readWordListInternal(
	lowercaser cases.Caser, chosenLanguage string,
	wordlistSupplier func(string) (string, error)) ([]string, error) {
	languageIdentifier := getLanguageIdentifier(chosenLanguage)
	list, available := wordListCache[languageIdentifier]
	if available {
		copiedList := make([]string, len(list))
		copy(copiedList, list)
		shuffleWordList(copiedList)
		return copiedList, nil
	}
	wordListFile, pkgerError := wordlistSupplier(languageIdentifier)
	if pkgerError != nil {
		return nil, pkgerError
	}
	tempWords := strings.Split(wordListFile, "\n")
	var words []string
	for _, word := range tempWords {
		word = strings.TrimSpace(word)
		if word == "" {
			continue
		}
		lastIndexNumberSign := strings.LastIndex(word, "#")
		if lastIndexNumberSign == -1 {
			words = append(words, lowercaser.String(word))
		} else {
			if "#i" == word[lastIndexNumberSign:] {
				continue
			}
			words = append(words, lowercaser.String(word[:lastIndexNumberSign]))
		}
	}
	wordListCache[languageIdentifier] = words
	copiedList := make([]string, len(words))
	copy(copiedList, words)
	shuffleWordList(copiedList)
	return copiedList, nil
}
func readWordListInternal ( lowercaser cases . Caser , chosenLanguage string , wordlistSupplier func ( string ) ( string , error ) ) ( [ ] string , error ) { languageIdentifier := getLanguageIdentifier ( chosenLanguage ) list , available := wordListCache [ languageIdentifier ] if available { copiedList := make ( [ ] string , len ( list ) ) copy ( copiedList , list ) shuffleWordList ( copiedList ) return copiedList , nil } wordListFile , pkgerError := wordlistSupplier ( languageIdentifier ) if pkgerError != nil { return nil , pkgerError } tempWords := strings . Split ( wordListFile , " \n " ) var words [ ] string for _ , word := range tempWords { word = strings . TrimSpace ( word ) if word == " " { continue } lastIndexNumberSign := strings . LastIndex ( word , " " ) if lastIndexNumberSign == - 1 { words = append ( words , lowercaser . String ( word ) ) } else { if " " == word [ lastIndexNumberSign : ] { continue } words = append ( words , lowercaser . String ( word [ : lastIndexNumberSign ] ) ) } } wordListCache [ languageIdentifier ] = words copiedList := make ( [ ] string , len ( words ) ) copy ( copiedList , words ) shuffleWordList ( copiedList ) return copiedList , nil }
readWordListInternal exists for testing purposes.
readWordListInternal exists for testing purposes .
//Newlines will just be empty strings //Since not all words use the tag system, we can just instantly return for words that don't use it. //The "i" is the "impossible" tag, meaning the word was rated as undrawable / unguessable.