gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/binaryx/convert.go (about)

     1  package binaryx
     2  
     3  import "unsafe"
     4  
     5  func StringToBytes(s string) []byte {
     6  	x := (*[2]uintptr)(unsafe.Pointer(&s))
     7  	h := [3]uintptr{x[0], x[1], x[1]}
     8  	return *(*[]byte)(unsafe.Pointer(&h))
     9  }