mirror of
https://github.com/smallnest/rpcx.git
synced 2025-09-26 20:21:14 +08:00
25 lines
395 B
Go
25 lines
395 B
Go
package util
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
func SliceByteToString(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
func StringToSliceByte(s string) []byte {
|
|
x := (*[2]uintptr)(unsafe.Pointer(&s))
|
|
h := [3]uintptr{x[0], x[1], x[1]}
|
|
return *(*[]byte)(unsafe.Pointer(&h))
|
|
}
|
|
|
|
func CopyMeta(src, dst map[string]string) {
|
|
if dst == nil {
|
|
return
|
|
}
|
|
for k, v := range src {
|
|
dst[k] = v
|
|
}
|
|
}
|