mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
16 lines
309 B
Go
16 lines
309 B
Go
package data
|
|
|
|
import "unsafe"
|
|
|
|
// Str2bytes Fast convert
|
|
func Str2bytes(s string) []byte {
|
|
x := (*[2]uintptr)(unsafe.Pointer(&s))
|
|
h := [3]uintptr{x[0], x[1], x[1]}
|
|
return *(*[]byte)(unsafe.Pointer(&h))
|
|
}
|
|
|
|
// Bytes2str Fast convert
|
|
func Bytes2str(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|