Sobes.tech
Junior — Middle

Explain the mechanism of cache reset or update when the data source changes.

sobes.tech AI

Answer from AI

When a value is written into a nil channel in Go, the program will deadlock forever. This happens because a nil channel is uninitialized and cannot send or receive values.

Example:

var ch chan int // ch == nil

func main() {
    ch <- 1 // this will hang
}

To avoid this, initialize the channel with make, for example:

ch := make(chan int)

Only after that can you safely send and receive from the channel.