Standard library / reflect

reflect.Value.UnsafeAddr()

Returns the address of an addressable Value as uintptr. It does not retain the referent; prefer Addr for typed pointers. Never save the address for later dereference. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) UnsafeAddr() uintptr

Return Value

uintptr

Returns the address of an addressable Value as uintptr.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { x := 1; v := reflect.ValueOf(&x).Elem(); fmt.Println(v.UnsafeAddr() != 0) }
Go Reference