package main import ( "fmt" "strings" ) func main() { text := " the quick brown fox " // Fields splits on runs of whitespace words := strings.Fields(text) fmt.Println(len(words), words) }
tokenize words, dropping empties