github.com/better-concurrent/guc@v0.0.0-20190520022744-eb29266403a1/reflect.go (about)

     1  package guc
     2  
     3  import "unsafe"
     4  
     5  type eface struct {
     6  	rtype unsafe.Pointer
     7  	data  unsafe.Pointer
     8  }
     9  
    10  func unpackEFace(obj interface{}) *eface {
    11  	return (*eface)(unsafe.Pointer(&obj))
    12  }
    13  
    14  func packEFace(rtype unsafe.Pointer, data unsafe.Pointer) interface{} {
    15  	var i interface{}
    16  	e := (*eface)(unsafe.Pointer(&i))
    17  	e.rtype = rtype
    18  	e.data = data
    19  	return i
    20  }