refactor: clean code

This commit is contained in:
Fu Diwei 2025-03-24 12:37:20 +08:00
parent 39f8484b2a
commit 53133db456
6 changed files with 18 additions and 0 deletions

View File

@ -88,6 +88,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error { func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error {
resp, err := c.sendRequest(method, path, params) resp, err := c.sendRequest(method, path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }

View File

@ -68,6 +68,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error { func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error {
resp, err := c.sendRequest(method, path, params) resp, err := c.sendRequest(method, path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }

View File

@ -74,6 +74,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error { func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error {
resp, err := c.sendRequest(method, path, params) resp, err := c.sendRequest(method, path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }

View File

@ -69,6 +69,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error { func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result BaseResponse) error {
resp, err := c.sendRequest(method, path, params) resp, err := c.sendRequest(method, path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }

View File

@ -56,6 +56,9 @@ func (c *Client) sendRequest(path string, params interface{}) (*resty.Response,
func (c *Client) sendRequestWithResult(path string, params interface{}, result BaseResponse) error { func (c *Client) sendRequestWithResult(path string, params interface{}, result BaseResponse) error {
resp, err := c.sendRequest(path, params) resp, err := c.sendRequest(path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }

View File

@ -73,6 +73,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result interface{}) error { func (c *Client) sendRequestWithResult(method string, path string, params interface{}, result interface{}) error {
resp, err := c.sendRequest(method, path, params) resp, err := c.sendRequest(method, path, params)
if err != nil { if err != nil {
if resp != nil {
json.Unmarshal(resp.Body(), &result)
}
return err return err
} }