Standard library / reflect
reflect.Value.UnsafePointer()
Returns an unsafe.Pointer for supported kinds. The caller must respect storage and lifetime requirements; the example compares a live pointer without reinterpretation. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) UnsafePointer() unsafe.PointerReturn Value
unsafe.Pointer
Returns an unsafe.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect" "unsafe")
func main() { x := 1; fmt.Println(reflect.ValueOf(&x).UnsafePointer() == unsafe.Pointer(&x)) }