server

net/rpc
net/rpc/jsonrpc

"google.golang.org/grpc"

type Yqmiot int 

func (iot *Yqmiot) Report(req ReportRequest, resp *ReportRespone) error {

}

var yqmiot Yqmiot
rpc.Register(&yqmiot)
rpc.HandleHTTP()
http.ListenAndServe(":8000", nil)

client

r, err = rpc.DialHTTP("tcp", "localhost:8000")

var req ReportRequest
var resp ReportRespone
req.xxx = xxx
err = r.Call("Yqmiot.Report", req, &resp) 

参考资料:
https://studygolang.com/articles/14336

标签: none

添加新评论