-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by ghexsel:
I have a loop in the exporter sender side that sends 10 items then closes the netchan. On the importer side, I have a loop to check if the channel is closed before trying to receive, but the channel doesn't appear to get closed. Instead, I see the "2010/05/23 16:39:38 importer header: EOF" message (in the importer receiver side). A simple solution would be to change the sender side to consider EOF a close signal on importer.go#run(). Exporter relevant bits: for i := 0; i < count; i++ { if closed(ch) { fmt.Printf("Can't send, channel is closed\n") os.Exit(1) } else { ch <- value {23 + i, "hello"} } } close(ch) Importer relevant bits: for { if closed(ch) { fmt.Printf("Can't receive, channel is closed\n") os.Exit(0) } else { v := <-ch fmt.Printf("%v\n", v) } }