Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 0fefbd7

Browse files
Nitpicks!
1 parent 989e4d4 commit 0fefbd7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

client.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ func New(baseURL string, cfg Config) (*Client, error) {
6262
}
6363

6464
func (c *Client) request(method, requestPath string, query url.Values, body io.Reader, responseStruct interface{}) error {
65-
var resp *http.Response
66-
var err error
67-
var bodyContents []byte
65+
var (
66+
req *http.Request
67+
resp *http.Response
68+
err error
69+
bodyContents []byte
70+
)
6871

6972
// retry logic
7073
for n := 0; n <= c.config.NumRetries; n++ {
71-
var r *http.Request
72-
r, err = c.newRequest(method, requestPath, query, body)
74+
req, err = c.newRequest(method, requestPath, query, body)
7375
if err != nil {
7476
return err
7577
}
@@ -79,7 +81,7 @@ func (c *Client) request(method, requestPath string, query url.Values, body io.R
7981
time.Sleep(time.Second * 5)
8082
}
8183

82-
resp, err = c.client.Do(r)
84+
resp, err = c.client.Do(req)
8385

8486
// If err is not nil, retry again
8587
// That's either caused by client policy, or failure to speak HTTP (such as network connectivity problem). A

client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestRequest_badURL(t *testing.T) {
108108
server, client := gapiTestTools(t, 200, `{"foo":"bar"}`)
109109
baseURL, err := url.Parse("bad-url")
110110
if err != nil {
111-
t.Fatal(err.Error())
111+
t.Fatal(err)
112112
}
113113
client.baseURL = *baseURL
114114
defer server.Close()

0 commit comments

Comments
 (0)