Can we store and retrieve data from a channel?
For instance, can I store c, in the code below, somewhere?
package main
import (
"fmt"
)
func main() {
c := make(chan int)
go func(){
c <- 42
}()
fmt.Println(<-c)
}
You can store it anywhere you like but channels are only a method for passing information within a Go program. Where the data comes from and what you do with it is entirely up to you.
I strongly recommend going through the Go tour, and specifically here for channels.