2018-05-14 10:59:18 +00:00
|
|
|
package tmpl
|
|
|
|
|
2018-12-15 04:39:50 +00:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2018-05-16 11:44:32 +00:00
|
|
|
var GetFrag = func(name string) [][]byte {
|
|
|
|
return nil
|
|
|
|
}
|
2018-12-15 04:39:50 +00:00
|
|
|
|
|
|
|
type WriteString interface {
|
|
|
|
WriteString(s string) (n int, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func StringToBytes(s string) (bytes []byte) {
|
|
|
|
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
|
|
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
|
|
|
slice.Data = str.Data
|
|
|
|
slice.Len = str.Len
|
|
|
|
slice.Cap = str.Len
|
|
|
|
runtime.KeepAlive(&s)
|
|
|
|
return bytes
|
|
|
|
}
|