Standard library / reflect
reflect.Value.Interface()
Return the represented value as an interface. Check CanInterface first, especially for unexported fields. Expected stdout: '42\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) Interface() (i any)Return Value
(i any)
Return the represented value as an interface.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { fmt.Println(reflect.ValueOf(42).Interface().(int)) }