Sending, receiving, and closing

The reflect.Value type offers a few methods that have to be used exclusively with channels, Send and Recv for sending and receiving, and Close for closing channels. Let's take a look at a sample use case of these functions and methods:

func main() {
t := reflect.ChanOf(reflect.BothDir, reflect.TypeOf(""))
v := reflect.MakeChan(t, 0)
go func() {
for i := 0; i < 10; i++ {
v.Send(reflect.ValueOf(fmt.Sprintf("msg-%d", i)))
}
v.Close()
}()
for msg, ok := v.Recv(); ok; msg, ok = v.Recv() {
fmt.Println(msg)
}
}

A full example is available here: https://play.golang.org/p/Gp8JJmDbLIL.