mirror of
https://github.com/status-im/status-go.git
synced 2025-01-20 19:52:42 +00:00
679391999f
* feat_: LogOnPanic linter * fix_: add missing defer LogOnPanic * chore_: make vendor * fix_: tests, address pr comments * fix_: address pr comments
21 lines
337 B
Go
21 lines
337 B
Go
package unsafebytes
|
|
|
|
import "unsafe"
|
|
|
|
func Pointer(b []byte) *byte {
|
|
return *(**byte)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
func String(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
func BytesOf(s string) []byte {
|
|
return *(*[]byte)(unsafe.Pointer(&sliceHeader{str: s, cap: len(s)}))
|
|
}
|
|
|
|
type sliceHeader struct {
|
|
str string
|
|
cap int
|
|
}
|