Channel

Understanding golang channel range

Here we go again with my golang self teaching, today with a topic I had hard time understanding correctly (and hope I actually did): range over channels along with goroutines.

First of all, let’s have a little reminder. We all know a goroutine live its own life and must be waited for at the main level, i.e. in this example:

package main

import "fmt"

func main() {
	go func() {
		fmt.Println("hello there")
	}()
}

run me on playground