Golang - Demonstrate how deadlock arises? Code Example

The code for Demonstrate how deadlock arises?

package main
  
func main() {
    c := make(chan int)
    select {
    case <-c:
    }
}

/*
Output:
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
main.main()
        /home/main.go:6 +0x52
*/
Code by IncludeHelp, on February 28, 2023 16:09

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.