awesome-patterns/playground/goroutine/deadlock_test.go

12 lines
376 B
Go
Raw Normal View History

2018-09-07 16:11:24 +03:00
package goroutine
import "testing"
// A deadlock happens when a group of goroutines are waiting for each other and none of them is able to proceed.
// The program will get stuck on the channel send operation waiting forever for someone to read the value.
// Go is able to detect situations like this at runtime.
func TestDeadlock(t *testing.T) {
c := make(chan int)
<-c
}