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

Commit 99d04c4

Browse files
authored
Merge pull request #105 from arnested/harden
Harden code
2 parents 7285732 + 01f52e5 commit 99d04c4

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
linters:
22
enable-all: true
33
disable:
4+
- depguard
45
- errname
56
- exhaustivestruct
6-
- nosnakecase
77
- exhaustruct
8+
- nosnakecase
89
- testpackage
910

1011
linters-settings:

post.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (c *Client) do(ctx context.Context, form url.Values) ([]byte, error) {
2929
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
3030

3131
resp, err := c.httpClient().Do(req)
32-
if err != nil {
32+
if (err != nil) || (resp == nil) {
3333
return nil, fmt.Errorf("failed to contact API: %w", err)
3434
}
3535

post_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestUpdateOK(t *testing.T) {
135135
_, err := client.Update(ctx, records)
136136
if err != nil {
137137
var netErr net.Error
138-
if errors.As(err, &netErr) && netErr.Timeout() {
138+
if errors.As(err, &netErr) && (netErr != nil) && netErr.Timeout() {
139139
t.Errorf("Timeoutsss: %s", netErr)
140140
} else {
141141
t.Errorf("Successful post should return OK but failed with error: %s", err)

0 commit comments

Comments
 (0)