github.com/hedzr/evendeep@v0.4.8/internal/tool/ptr_test.go (about)

     1  package tool
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestPtrOf(t *testing.T) {
     9  
    10  	var i = 100
    11  	v := reflect.ValueOf(&i)
    12  	vind := Rindirect(v)
    13  	vp := PtrOf(vind)
    14  	t.Logf("ptr of i: %v, &i: %v", vp.Interface(), &i)
    15  	vp.Elem().SetInt(99)
    16  	t.Logf("i: %v", i)
    17  
    18  }