stopper := stop.NewStopper() defer stopper.Stop() // ... code ... stopper.Stop()
stopper := stop.NewStopper() // ... code ... if stopper.ShouldStop() { return // Shutdown initiated }Overall, the `util/stop` package can be used to manage the lifetime and shutdown of goroutines in a graceful way.