Illustration for Medium article “Shutdown All Goroutines”
seen from China

seen from Italy
seen from Türkiye
seen from China

seen from Malaysia

seen from United States
seen from Ghana
seen from United States

seen from Spain

seen from United States
seen from China

seen from Indonesia

seen from Türkiye
seen from Spain

seen from Saudi Arabia
seen from Türkiye
seen from China

seen from China
seen from United Kingdom
seen from Netherlands
Illustration for Medium article “Shutdown All Goroutines”
One of the early Feedback received for Social Paster has been that people wanted Login with Facebook functionality. And Heeding the feedback, I have started working on it. Login with Facebook funct...
A good small example of channels usage within Go for async purposes.
Banging my head against channels.
Stop goroutine by closing a quit channel
It's a good practice to stop a goroutine by closing a 'quit' channel.
doSomething := make(chan int) quit := make(chan int) go func() { select { case <- doSomething: fmt.Println("done") case <- quit: fmt.Println("quit") } }() close(quit) // stop the goroutine
It's better than sending a variable to 'quit' channel like,
quit <- 1 // stop the goroutine
because you can stop more than one goroutines by closing it.
Sleep forever
Sleep forever select{}