Top "Goroutine" questions

A goroutine is a lightweight thread of execution that is managed by the Go language runtime.

Why does Go panic on writing to a closed channel?

Why does Go panic on writing to a closed channel? While one can use the value, ok := <-channel idiom …

go concurrency channel goroutine panic
What is the difference between switch and select in Go?

Is there any difference between switch and select in Go, apart from the fact that one takes an argument and …

go switch-statement goroutine
How to lock/synchronize access to a variable in Go during concurrent goroutines?

In his answer to this question: Golang for Windows erratic behavior? user @distributed recommended to lock/synchronize access to a …

go goroutine
How do goroutines work? (or: goroutines and OS threads relation)

How can other goroutines keep executing whilst invoking a syscall? (when using GOMAXPROCS=1) As far as I'm aware of, when …

concurrency go goroutine
Why is time.sleep required to run certain goroutines?

In the GO tutorial, we have this slide: Goroutines package main import ( "fmt" "time" ) func say(s string) { for i := 0; …

go goroutine
How can I use 'time.After' and 'default' in Golang?

I'm trying to understand a simple code of Golang routines: package main import ( "fmt" "time" ) func sleep(seconds int, endSignal …

go goroutine
Append not thread-safe?

I noticed that if I tried appending to a slice using goroutines inside a for loop, there would be instances …

go concurrency append slice goroutine
Number of threads used by Go runtime

How many threads can the Go runtime (scheduler, garbage collector, etc.) use? For example, if GOMAXPROCS is 10, how many of …

multithreading go docker concurrency goroutine
Break out of select loop?

I'm trying to use a select in a loop to receive either a message or a timeout signal. If the …

select concurrency go goroutine
How to test if a goroutine has been called while unit testing in Golang?

suppose that we have a method like this: func method(intr MyInterface) { go intr.exec() } In unit testing method, we …

unit-testing go goroutine