gosora/tmplstub.go

48 lines
1.1 KiB
Go
Raw Normal View History

2018-05-14 10:59:18 +00:00
package main
import (
2022-02-21 03:32:53 +00:00
//"reflect"
//"runtime"
//"unsafe"
"github.com/Azareal/Gosora/uutils"
)
// TODO: Add a safe build mode for things like Google Appengine
var GetFrag = func(name string) [][]byte {
2022-02-21 03:32:53 +00:00
return nil
}
type WriteString interface {
2022-02-21 03:32:53 +00:00
WriteString(s string) (n int, err error)
}
var StringToBytes = uutils.StringToBytes
var BytesToString = uutils.BytesToString
var Nanotime = uutils.Nanotime
/*
func StringToBytes(s string) (bytes []byte) {
2022-02-21 03:32:53 +00:00
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
}
func BytesToString(bytes []byte) (s string) {
2022-02-21 03:32:53 +00:00
slice := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
str := (*reflect.StringHeader)(unsafe.Pointer(&s))
str.Data = slice.Data
str.Len = slice.Len
runtime.KeepAlive(&bytes)
return s
}
//go:noescape
//go:linkname nanotime runtime.nanotime
func nanotime() int64
func Nanotime() int64 {
2022-02-21 03:32:53 +00:00
return nanotime()
}*/