How come something simple like this does not work?
c1 := make(chan string)
c1 <- "foo"
fmt.Println(<-c1)
But if I put it in a go routine it works?
c1 := make(chan string)
go func() {
c1 <- "foo"
}()
fmt.Println(<-c1)
The question might seem simple and stupid, but I'm trying to understand why I can't do this and I don't know of anything better to ask in this case.