mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-06 18:29:05 +01:00
19 lines
290 B
Go
19 lines
290 B
Go
|
// +build !appengine
|
||
|
|
||
|
package fwd
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"unsafe"
|
||
|
)
|
||
|
|
||
|
// unsafe cast string as []byte
|
||
|
func unsafestr(b string) []byte {
|
||
|
l := len(b)
|
||
|
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
|
||
|
Len: l,
|
||
|
Cap: l,
|
||
|
Data: (*reflect.StringHeader)(unsafe.Pointer(&b)).Data,
|
||
|
}))
|
||
|
}
|