Standard library / reflect

reflect.Value.Close()

Closes a channel; closing an already closed or nil channel panics. Expected stdout: 'false\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) Close()

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() {  ch := make(chan int, 1)  v := reflect.ValueOf(ch)  v.Close()  _, ok := <-ch  fmt.Println(ok)}
Go Reference