Skip to content

Instantly share code, notes, and snippets.

@volodimyr
Created September 8, 2018 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volodimyr/efae62acc0644e6d0a3fb0d559a68fca to your computer and use it in GitHub Desktop.
Save volodimyr/efae62acc0644e6d0a3fb0d559a68fca to your computer and use it in GitHub Desktop.
Deadlock concurrency in golang
package main
import "fmt"
var (
first chan string
second chan string
)
func main() {
go forever()
second <- "From main"
}
func forever() {
for {
select {
case f := <-first:
fmt.Println(f)
case s := <-second:
block(s)
}
}
}
func block(str string) {
first <- "From block function " + str
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment