Overview The zero value of the channel is nil. Hence only declaring a channel creates a nil channel as default zero value of the channel is nil. Below is the result of send and…
Tag: golang
Channel in Go (Golang)
This is the chapter 24 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – Select StatementPrevious Tutorial – Goroutines Now let’s…
Select statement with timeout in Go (Golang)
Overview Timeout in select can be achieved by using After() function of time package. Below is the signature of After() function. The After function waits for d duration to finish and then it…
Empty select or select with no case in Go (Golang)
Overview Select block without any case statement is empty select. The empty select will block forever as there is no case statement to execute. We know that select statement gets blocked until…
Break statement in Select in Go (Golang)
Overview Break keyword can be used in select to terminate the execution of innermost statement similar to switch and for look. Below is the break keyword example in select. Code Output break statement will terminate…
Fallthrough keyword in select statement in Go (Golang)
Overview Select doesn’t allow fallthrough keyword to select multiple cases. Fallthrough keyword can only be used in switch statement to select multiple cases Only one case out of ready cases will be…
Select versus switch in Go (Golang)
Overview Below are some of the differences between switch and select statement In switch each of the case statement is an expression while in select each of the case statement is either…
Select with default case in Go (Golang)
Overview Similar to switch select can also have a default case. This default case will be executed if no send it or receive operation is ready on any of the case statement….
Select statement with a for loop outside in Go (Golang)
Overview There are two cases of for loop being outside a select statement Finite for loop outside select statement Infinite for loop outside select statement Let’s look at each one by one…
Select Statement in Go (Golang)
This is the chapter 25 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – ErrorPrevious Tutorial – Channel Now let’s check…