add bad library

This commit is contained in:
MathieuHa
2022-10-16 23:10:39 +02:00
parent 395c80dccf
commit 87ed9e9c4e
62 changed files with 17340 additions and 22 deletions
+23
View File
@@ -0,0 +1,23 @@
//go:build !appengine
// +build !appengine
package util
import (
"unsafe"
)
// BytesToString converts byte slice to string.
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
// StringToBytes converts string to byte slice.
func StringToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{s, len(s)},
))
}