mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-06 00:16:49 +08:00
17 lines
232 B
Go
17 lines
232 B
Go
package utils
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
func ToByte(s string) []byte {
|
|
p := unsafe.StringData(s)
|
|
b := unsafe.Slice(p, len(s))
|
|
return b
|
|
}
|
|
|
|
func FromByte(b []byte) string {
|
|
p := unsafe.SliceData(b)
|
|
return unsafe.String(p, len(b))
|
|
}
|