From 9efca0097fc31213f8eb516b3d7ce8ad859bb881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9E=A8=E7=85=8A?= Date: Wed, 3 Jun 2020 11:23:11 +0800 Subject: [PATCH] =?UTF-8?q?client=E5=AF=B9=E5=A4=96=E5=85=AC=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 402e7f8..5c92aed 100644 --- a/client.go +++ b/client.go @@ -7,7 +7,7 @@ import ( "time" ) -type client struct { +type Client struct { Request *pack.Request Response *pack.Response Http *http.Request @@ -15,14 +15,14 @@ type client struct { } // 初始化一个客户端 -func Client(addr string, method string, params interface{}) (*client, error) { +func NewClient(addr string, method string, params interface{}) (*Client, error) { httpRequest, err := http.NewRequest(http.MethodPost, addr, nil) if err != nil { return nil, err } httpRequest.Header.Set("User-Agent", "Go Yar Rpc-0.1") - c := &client{ + c := &Client{ Request: pack.NewRequest(addr, method, params), Response: new(pack.Response), Http: httpRequest, @@ -33,13 +33,13 @@ func Client(addr string, method string, params interface{}) (*client, error) { } // 设置返回值结构体 -func (c *client) SetResponseRetStruct(retVal interface{}) *client { +func (c *Client) SetResponseRetStruct(retVal interface{}) *Client { c.Response.Retval = retVal return c } // 开始发送请求数据 -func (c *client) Send() error { +func (c *Client) Send() error { packHandler := pack.GetPackHandler(c.Request.Protocol) data, err := packHandler.Encode(c.Request) if err != nil {