mirror of
https://github.com/fumiama/fumitok.git
synced 2026-06-11 13:40:25 +08:00
init
This commit is contained in:
15
helper.go
Normal file
15
helper.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package fumitok
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// BytesToString 没有内存开销的转换
|
||||
func BytesToString(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
||||
|
||||
// StringToBytes 没有内存开销的转换
|
||||
func StringToBytes(s string) (b []byte) {
|
||||
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
}
|
||||
Reference in New Issue
Block a user