add printer
This commit is contained in:
31
vo.go
Normal file
31
vo.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"C"
|
||||
"encoding/json"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Reply struct {
|
||||
Status int `json:"status"`
|
||||
Err string `json:"err"`
|
||||
Result interface{} `json:"result"`
|
||||
}
|
||||
|
||||
func NewErr(err error) *C.char {
|
||||
e := Reply{Status: 1, 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: 0, Result: data}
|
||||
b, err := json.Marshal(e)
|
||||
if err != nil {
|
||||
log.Println("Error json.Marshal:", err.Error())
|
||||
}
|
||||
return C.CString(string(b))
|
||||
}
|
||||
Reference in New Issue
Block a user