Check out example codes for "select channel golang". It will help you in understanding the concepts better.

Code Example 1

package main

import (
	"fmt"
)

func main() {
	c := make(chan int)

	go sender(c)
	receiver(c)
}

func sender(c chan<- int) {
	defer close(c)

	for i := 0; i < 10; i++ {
		c <- i
	}
}

func receiver(c <-chan int) {
	for {
		select {
		case v, ok := <-c:
			if !ok {
				return
			}
			fmt.Println(v)
		}
	}
}

Learn ReactJs, React Native from akashmittal.com