// Chapter 37 example: a goroutine sends a value, and main receives it. // Run with: go run exercises/37/01-first-channel.go package main import ( "fmt" "time" ) // slowSquare pretends that squaring a number takes a while. func slowSquare(n int) int { time.Sleep(300 * time.Millisecond) return n * n } func main() { answers := make(chan int) go func() { answers <- slowSquare(7) }() fmt.Println("Waiting for the answer...") answer := <-answers fmt.Println("The answer is", answer) }