// Homework 37, challenge: Word lengths. // // Build a pipeline of three stages, each in its own goroutine except the // last, joined by channels: // // 1. words(text, out) splits text into words with strings.Fields and sends // each word on out, then closes out. // 2. lengths(in, out) receives words and sends a wordLength for each one, // then closes out. // 3. main receives every wordLength, prints it as "send 4", and at the end // prints the longest word. // // Use send-only (chan<-) and receive-only (<-chan) channel types in the // parameters of words and lengths. // // Run with: go run exercises/37/homework/04-word-lengths.go package main import "fmt" // wordLength is one word and how many letters it has. type wordLength struct { word string length int } func main() { text := "goroutines send values over channels to each other" // TODO: write your code here, in place of these placeholder lines: fmt.Println("TODO: measure the words in:", text) _ = wordLength{} }