dal/cgo/dal.go
Anton Nesterov 87e3fdd18d
[feat] prepare shared lib
Signed-off-by: Anton Nesterov <anton@demiurg.io>
2024-08-19 17:59:55 +02:00

32 lines
553 B
Go

package main
// #include <stdlib.h>
import "C"
import (
"strings"
"unsafe"
"l12.xyz/dal/facade"
)
//export InitSQLite
func InitSQLite(pragmas *C.char) {
str := C.GoString(pragmas)
pragmasArray := strings.Split(str, ";")
facade.InitSQLite(pragmasArray)
}
//export HandleQuery
func HandleQuery(input *C.char) *C.char {
var in, out []byte
inPtr := unsafe.Pointer(input)
defer C.free(inPtr)
in = C.GoBytes(inPtr, C.int(len(C.GoString(input))))
facade.HandleQuery(&in, &out)
output := C.CString(string(out))
return output
}
func main() {}