Explore >> Select a destination


You are here

aarol.dev
| | timilearning.com
3.9 parsecs away

Travel
| | This post will contain some examples of good and bad Go code, using them to show common mistakes that can be made when starting to build concurrent programs, and how those can be corrected. It will cover goroutines, mutexes, condition variables, and channels.
| | konradreiche.com
4.4 parsecs away

Travel
| | Starting a goroutine is as easy as adding the go keyword in front of a method, but managing the lifecycle of a goroutine is not. If you only need to start a few goroutines and wait for their completion, you are off the hook thanks to sync.WaitGroup. However, what if a goroutine has to run for a specific duration or repeatatly in a loop until the initiating code terminates? Does it matter? After all, if the main goroutine terminates, any other goroutine will also stop. It does matter, because depending on what the goroutines are doing, it might leave your system in an inconsistent or invalid state. Channels are a commonly used to signal to a goroutine that it can shut down, but I often see the use of a signaling channel, for example chan bool or chan struct{}...
| | hjr265.me
3.6 parsecs away

Travel
| | Concurrency is one of the central features of Go. And, to build concurrent programs in Go, you need goroutines. A goroutine is like a thread, but lighter. Much lighter. And, like any other built-in feature of Go, using it is dead simple: 1 2 3 4 5 6 7 package main func main() { go func() { println("Hello World") // Print "Hello World" from a different goroutine. }() } Wait. That didn't print anything.
| | morestina.net
24.8 parsecs away

Travel
| Several months ago a StackOverflow user asked an interesting question: Imagine we have an iterator, say iter(range(1, 1000)). And we have two functions, each accepting an iterator as the only param...