Hello,

This is my first time on this mailing list. I'm trying to learn about Go 
concurrency patterns.

I am looking at the Stopping Short section and in particular at the 
following code:

https://blog.golang.org/pipelines#TOC_5.:~:text=%2F%2F%20Consume%20the%20first%20value%20from%20the,%7D

I think that goes in main.

My code is linked 
here: https://gist.github.com/nchelluri/186ed96ad1612f33b25922fa102cc5bd

It seems to me that while the comment says

// Since we didn't receive the second value from out,
// one of the output goroutines is hung attempting to send it.

the program will actually terminate. I think that is because of

https://golang.org/ref/spec#Program_execution:~:text=Program%20execution%20begins%20by%20initializing%20the,for%20other%20(non%2Dmain)%20goroutines%20to%20complete.

(In particular, the last sentence seems relevant: "Program execution begins 
by initializing the main package and then invoking the function main. When 
that function invocation returns, the program exits. *It does not wait for 
other (non-main) goroutines to complete.*").

I just wanted to know if there was a way to tell that the goroutines c1, c2 
actually are hung. Could I in my head add the sentences "While the program 
terminates, that is only because the main goroutine has finished its 
execution. One of the sending goroutines will still be waiting to send its 
value to its output channel when this happens." to the end of the paragraph 
that says "In our example pipeline, if a stage fails to consume all the 
inbound values, the goroutines attempting to send those values will block 
indefinitely:"?

Thanks for your help!

- nc

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2f3aa748-5515-42e4-89b2-ba76c58ac2cfn%40googlegroups.com.

Reply via email to