feat: super 包添加 []byte、string 零拷贝转换函数
This commit is contained in:
parent
b6f28dd743
commit
506e0f2ee4
|
@ -0,0 +1,11 @@
|
|||
package super
|
||||
|
||||
import "unsafe"
|
||||
|
||||
func StringToBytes(s string) []byte {
|
||||
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
}
|
||||
|
||||
func BytesToString(b []byte) string {
|
||||
return unsafe.String(&b[0], len(b))
|
||||
}
|
Loading…
Reference in New Issue