I stumbled upon what I found to be surprising behavior when sending from one channel directly to another channel:
package main
import (
"fmt"
)
func main() {
my_chan := make(chan string)
chan_of_chans := make(chan chan string)
go func() {
my_chan <- "Hello"
}()
go func() {
chan_of_chans <- my_chan
}()
fmt.Println(<- <- chan_of_chans)
}
I expected <- my_chan to send "Hello" type string. However, it sends type chan string and my code runs fine. This means that what is being (string or chan string) sent depends on the type of the receiver.
I tried naive googling, but since I am not familiar with proper terminology I came up with nothing. Is there a proper term associated with the above behavior? Any additional insight is great of course.