2018-07-23 11:12:14 +08:00
|
|
|
package bencode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Wow Go is retarded.
|
|
|
|
var marshalerType = reflect.TypeOf(func() *Marshaler {
|
|
|
|
var m Marshaler
|
|
|
|
return &m
|
|
|
|
}()).Elem()
|
|
|
|
|
|
|
|
// Wow Go is retarded.
|
|
|
|
var unmarshalerType = reflect.TypeOf(func() *Unmarshaler {
|
|
|
|
var i Unmarshaler
|
|
|
|
return &i
|
|
|
|
}()).Elem()
|
|
|
|
|
|
|
|
func bytesAsString(b []byte) string {
|
2021-09-14 08:41:04 +08:00
|
|
|
return *(*string)(unsafe.Pointer(&b))
|
2018-07-23 11:12:14 +08:00
|
|
|
}
|