Standard library / reflect

reflect.SelectRecv

Receive case uses a channel and an invalid Send field. Expected stdout: '4 true\n'.

Formal Syntax & Structure

go syntaxgo
const SelectRecv SelectDir = 2

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() {  ch := make(chan int, 1)  v := reflect.ValueOf(ch)  ch <- 4  _, x, ok := reflect.Select([]reflect.SelectCase{{Dir: reflect.SelectRecv, Chan: v}})  fmt.Println(x.Int(), ok)}
Go Reference