DEV Community

Discussion on: Pitch me on Go

Collapse
 
wesen profile image
Manuel Odendahl

I like pointing people who already know programming to "Effective Go". If you have no experience with concurrency and threading, that will take some additional learning. Don't go in there just YOLOing channels and goroutines left and right.

My rules for goroutines:

  • know when, where and why a goroutine is created
  • for every goroutine, make sure it can properly be cancelled
  • for every goroutine, think and design how it would report errors
  • for every goroutine, know exactly when it finishes, and how its results are handled
  • use errgroup to start goroutines, and write actual goroutine bodies as Run(ctx *context.Context, args...) error