¿Por qué no se ejecuta mi gorutina?
Estoy aprendiendo Go y quería probar goroutines y canales.
Aquí está mi código:
package main
import "fmt"
func main(){
messages := make(chan string,3)
messages <- "one"
messages <- "two"
messages <- "three"
go func(m *chan string) {
fmt.Println("Entering the goroutine...")
for {
fmt.Println(<- *m)
}
}(&messages)
fmt.Println("Done!")
}
Y aquí está el resultado:
Done!
No entiendo por qué mi gorutina nunca se ejecuta. El mensaje "Entrando en la rutina" no se imprime y no tengo ningún mensaje de error.