|
You are here |
aarol.dev | ||
| | | | |
konradreiche.com
|
|
| | | | | 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{}... | |
| | | | |
jbrandhorst.com
|
|
| | | | | Sometimes when you're writing a server, you've got a function that consumes a lot of memory while running, or some other resource, and you might be worrying that a sudden burst of requests could crash the server, since gRPC by default will just spawn another goroutine to handle any incoming requests, oblivious to the danger. In these situations, it can be useful to implement some custom request throttling. Here I'll show an easy way to accomplish this with the use of a Go channel. | |
| | | | |
hjr265.me
|
|
| | | | | 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. | |
| | | | |
endormi.io
|
|
| | | I maintain a couple of open source projects and contribute to many projects. Here are just a few of the projects that I maintain: automation - Collection of my automated tasks written in Python. awesome-dj - List of reasons why Django is awesome for web development && Django bootstrap boilerplate. devisle/advanced-react-cli - An NPM package which aims to provide a better way to install packages for your react application through an intuitive CLI. | ||