github.com/wfusion/gofusion@v1.1.14/common/utils/gomonkey/creflect/be1.16.go (about)

     1  //go:build !go1.17
     2  // +build !go1.17
     3  
     4  package creflect
     5  
     6  import (
     7  	"unsafe"
     8  )
     9  
    10  // name is an encoded type name with optional extra data.
    11  type name struct {
    12  	bytes *byte
    13  }
    14  
    15  func (n name) name() (s string) {
    16  	if n.bytes == nil {
    17  		return
    18  	}
    19  	b := (*[4]byte)(unsafe.Pointer(n.bytes))
    20  
    21  	hdr := (*String)(unsafe.Pointer(&s))
    22  	hdr.Data = unsafe.Pointer(&b[3])
    23  	hdr.Len = int(b[1])<<8 | int(b[2])
    24  	return s
    25  }