Programming Code Center(PCC)
[GO]

(PCC)::[How-to-iterate-over-values-received-from-a-channel-using-Range-over-Channels-in-go-language]::[go]

File Name : range-over-channels.go

package main

import "fmt"

func main() {

    queue := make(chan string, 2)
    queue <- "one"
    queue <- "two"
    close(queue)

    for elem := range queue {
        fmt.Println(elem)
    }
}

Output :

range-over-channels.jpg