package libgofunc import ( /* #include */ "C" "encoding/json" "log" ) type Reply struct { Status string `json:"status"` // "ok", "error" Err string `json:"err"` Result interface{} `json:"result"` } func NewErr(err error) *C.char { e := Reply{Status: "error", Err: err.Error()} b, err := json.Marshal(e) if err != nil { log.Println("Error json.Marshal:", err.Error()) } return C.CString(string(b)) } func NewOk(data interface{}) *C.char { e := Reply{Status: "ok", Result: data} b, err := json.Marshal(e) if err != nil { log.Println("Error json.Marshal:", err.Error()) } return C.CString(string(b)) }