Standard library / reflect

reflect.Value.CanInterface()

Report whether Interface may be called without panic; unexported fields cannot be exposed this way. Expected stdout: 'false\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) CanInterface() bool

Return Value

bool

Report whether Interface may be called without panic; unexported fields cannot be exposed this way.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { fmt.Println(reflect.ValueOf(struct{ x int }{1}).Field(0).CanInterface()) }
Go Reference