func writeResponse(c *serverCodec) error { head := rpc.Response{} head.ServiceMethod = "TestFunc" head.Seq = 2 head.Error = "call failed" body := testpb.Result{} body.Title = proto.String("www.zhihu.com") return c.WriteResponse(&head, &body) }
func readResponse(c *clientCodec) error { head := rpc.Response{} if err := c.ReadResponseHeader(&head); err != nil { return err } body := testpb.Result{} if err := c.ReadResponseBody(&body); err != nil { return err } fmt.Printf("head: %v, body: %v\n", head, body.GetTitle()) return nil }