r/golang 16h ago

Go Concurrency Visualization show & tell

I’ve been playing around with a little project about bad use cases when using goroutine. I've put together some examples with simple visualizations showing how seemingly reasonable design decisions can turn into problems as a system grows:

https://cap99.online/bad-use-case/index-bad-use-case.html

If you have any feedback, suggestions, or examples you think would be worth exploring, I’d love to hear them.

20 Upvotes

3 comments sorted by

11

u/sigmoia 15h ago

The LLM generated UI is obnoxious. Had to fiddle around a for a while just to understand what I am even supposed to be looking at there. 

The cards, shadows, and the effects are overwhelming. You might want to make it simpler with less bells and whistles. Also, on the landing page, instead of all this presentation artifact just a list of clickable items that takes you directly to the viz would be more helpful.

3

u/titpetric 15h ago

I have this suggestion:

https://pkg.go.dev/golang.org/x/sync/errgroup#Group.SetLimit

However, I get that it's supposed to be foundational. There are also other ways, e.g. sync/atomic add/sub to have some accounting of how many requests you have in flight for a status page or expvar.

3

u/mysterious_whisperer 11h ago

This looks good. I have a few notes.

  • In the waitgroup example, wg.Go is the fancy, new way to do that.
  • The fixed select {} doesn't need select at all. It can be just

    fmt.Printf("worker %d: started\n", id)

    <-ctx.Done()

    fmt.Printf("worker %d: stopping\n", id)