This is the chapter 26 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – Error -Part 2Previous Tutorial – Select Statement…
Author: admin
Ignoring errors in Go (Golang)
Overview Underscore (‘_’) operator can be used to ignore the error returned from a function call. Before we see a program it’s important to note that error should never be ignored. It…
Wrapping and Un-wrapping of error in Go (Golang)
Wrapping of error In go, error can wrap another error as well. What does the wrapping of error mean? It means to create a hierarchy of errors in which a particular instance…
Get underlying type from error or error assertion in Go (Golang)
Overview There are two ways of getting the underlying type Using the .({type}) assert If the assert succeeds then it will return the corresponding error otherwise it will panic. Below is the…
Comparing error or error equality in Go (Golang)
Overview First of all, what is meant by equality of the error? As you already know that error is represented by the error interface in go. In go, two interfaces are equal…
For-range loop for a channel in Go (Golang)
For range loop can be used to receive data from the channel until it is closed. Do note that for- range loop will keep receiving from the channel the only way for range…
Read/receive all values from a channel in Go (Golang)
Overview For range loop can be used to receive data from the channel until it is closed. Do note that for- range loop will keep receiving from the channel the only way for…
All operations/function on a channel in Go (Golang)
Overview Below operations/functions are applicable for channel in golang Send the data to the channel Receive the data from the channel Close a channel Length of a channel using len() function Capacity…
Length and capacity of a channel in Go (Golang)
Overview Length, as well as capacity only, applies to the buffered channel. The length of a channel is the number of elements that are already there in the channel whereas the capacity…
Channel Direction in Go (Golang)
Overview It is possible to create bidirectional as well as uni-directional channels in golang. A channel can be created to which we can only send data, as well as a channel, can be…