Golang - Demonstrate how to resolve the deadlock problem using the default case? Code Example

The code for Demonstrate how to resolve the deadlock problem using the default case?

package main
  
import "fmt"
  
func main() {
    c := make(chan int)
    select {
    case <-c:
    default:
        fmt.Println("Default It Is.")
    }
}

/*
Output:
Default It Is
*/
Code by IncludeHelp, on February 28, 2023 16:13

Comments and Discussions!

Load comments ↻






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