Enable golangci-lint (#49)
## Summary: It would be nice to have some linting beyond `go vet`! Now we do. I started by copying the config from Khan/webapp. I did remove a couple of staticcheck checks that I didn't feel were useful. (Note also that exportloopref is the replacement for scopelint in newer golangci-lint.) Included are all the needed lint fixes; most are stylistic but the changes in the example are a (minor) bugfix. Fixes #22. Issue: https://github.com/Khan/genqlient/issues/22 ## Test plan: make check Author: benjaminjkraft Reviewers: aberkan, dnerdy, benjaminjkraft, csilvers, MiguelCastillo Required Reviewers: Approved by: aberkan, dnerdy Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint Pull request URL: https://github.com/Khan/genqlient/pull/49
This commit is contained in:
+5
-4
@@ -46,9 +46,9 @@ type Client interface {
|
||||
}
|
||||
|
||||
type client struct {
|
||||
httpClient *http.Client
|
||||
endpoint string
|
||||
method string
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// NewClient returns a Client which makes requests to the given endpoint,
|
||||
@@ -64,7 +64,7 @@ func NewClient(endpoint string, httpClient *http.Client) Client {
|
||||
if httpClient == nil {
|
||||
httpClient = http.DefaultClient
|
||||
}
|
||||
return &client{endpoint, http.MethodPost, httpClient}
|
||||
return &client{httpClient, endpoint, http.MethodPost}
|
||||
}
|
||||
|
||||
type payload struct {
|
||||
@@ -109,9 +109,10 @@ func (c *client) MakeRequest(ctx context.Context, opName string, query string, r
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
respBody, err := ioutil.ReadAll(resp.Body)
|
||||
var respBody []byte
|
||||
respBody, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
respBody = []byte("<unreadable>")
|
||||
respBody = []byte(fmt.Sprintf("<unreadable: %v>", err))
|
||||
}
|
||||
return fmt.Errorf("returned error %v: %s", resp.Status, respBody)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user