mirror of
https://github.com/fumiama/tienyik.git
synced 2026-06-28 15:00:23 +08:00
feat: add log & supporting packages
This commit is contained in:
13
internal/textio/str.go
Normal file
13
internal/textio/str.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package textio
|
||||
|
||||
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