Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang goroutine result issue #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

corentone
Copy link

Are we correctly waiting for result processing?

Since we only wait on wg.Wait() it could return before all the println have happened since we dont wait for that.
We should somehow also have a mechanism to wait for all the messages to have been processed. Im still trying to think what would be the cleanest solution.

@@ -160,6 +160,7 @@ func main() {
messages <- 3
}()
go func() {
// we should wait for completion here?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obivously dont merge me :)

@corentone
Copy link
Author

corentone commented Oct 20, 2020

Tagging you per the article; sorry its super old, I was looking for a nice pattern and found your blog but Im thinking there is a potential issue :)
@nathanleclaire

The playground that shows it:
https://play.golang.com/p/Lh2bQcJedso

@corentone corentone changed the title Golang goroutine Golang goroutine result issue Oct 20, 2020
@corentone
Copy link
Author

I found a solution with just adding another wait group;
https://play.golang.com/p/4-89F4fPWTc

For your article it may be easier to just not deal with the result and do the printing in the work goroutine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant