FlashKeepers

Go · College · College and University

Go III: Goroutines and Channels

Goroutines, channels, select, sync package, WaitGroup, context and common concurrency patterns in Go.

About this set

40 basic cards for College Go. It opens with "What is a goroutine?" and "What keyword launches a goroutine?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is a goroutine?
Show answerA lightweight thread of execution managed by the Go runtime, cheaper than OS threads
What keyword launches a goroutine?
Show answergo
What happens to all goroutines when main() exits?
Show answerThey are terminated immediately, regardless of whether they finished
How many goroutines can a Go program typically handle?
Show answerThousands to millions, depending on memory and system resources
Goroutines are scheduled by which Go runtime component?
Show answerThe scheduler, which multiplexes goroutines onto OS threads
What is a channel?
Show answerA typed conduit for sending and receiving values between goroutines
Syntax to create an unbuffered channel of int
Show answermake(chan int)
Syntax to create a buffered channel of string with capacity 5
Show answermake(chan string, 5)
Syntax to send value x to channel c
Show answerc <- x
Syntax to receive from channel c into variable v
Show answerv := <-c
How to check if a value received from channel c is from a closed channel?
Show answerv, ok := <-c; ok is false if the channel is closed
What happens when you send to a closed channel?
Show answerpanic
What value is returned when receiving from a closed channel?
Show answerThe zero value of the channel type
Syntax to close a channel c
Show answerclose(c)
How to iterate over values sent to channel c until it closes?
Show answerfor v := range c { ... }

25 more cards in the app

Study this set free