我对发送者频道的影响有疑问

I am not clear about why the print statement in func a1 will not print anything if I remove <-result in func a2. I think before we send something into result, the print statement should be executed, and <-result should not have some effect on that.

func a2(){
    x := 3
    result := make(chan int, 10)
    input := make(chan int, 10)
    go a1(x, input, result)
    input <- 4
    <-result
}

func a1(x int, input <-chan int, result chan<- int){
    y := <-input
    fmt.Println("hello", y)
    result <- x
}

However, then I tried the following code: it will print hello no matter whether I have <-result or not.

func a2(){
    x := 3
    result := make(chan int, 10)
    go a1(x, result)
    <-result
}

func a1(x int, result chan<- int){
    fmt.Println("hello")
    result <- x
}

Can you explain this in a detailed way so that a beginner can understand this? It seems like input <-chan int this input channel is doing something that causes the difference.

Because without <-result, a2() returns and the program terminates, assuming a2() is the only thing main() does. Probably a1() never even wakes up, because input channel is buffered, and writing to it will not block. If you make it unbuffered, then a1() will wake up before a2() returns, but that still doesn't guarantee that println will run.

With <-result, a2() waits for a1() to read from the result channel, which is after println. That's the only safest way to ensure println runs.