Skip to content

Commit

Permalink
DE-1353 Add bodyclose and gosec linters (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc authored Nov 9, 2024
1 parent b08f773 commit a3a5d84
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ linters:
- errcheck # Mandatory. Do not disable.
- ineffassign # Mandatory. Do not disable.
- staticcheck # Mandatory. Do not disable.
- gosec
- bodyclose # https://github.com/timakin/bodyclose
- gomodguard
- nolintlint

# TODO:
# - bodyclose # https://github.com/timakin/bodyclose
# - gocritic
# - goimports
# - gosec
# - gosimple
# - govet
# - noctx
Expand Down
19 changes: 14 additions & 5 deletions exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, er

resp, err := r.Client.Do(req)
if err != nil {
if resp != nil && resp.StatusCode == http.StatusFound {
url, err := resp.Location()
if err != nil {
return "", fmt.Errorf("while parsing 302 redirect url: %s", err)
if resp != nil { // TODO(vtopc): not nil err and resp at the same time, is that possible at all?
defer resp.Body.Close()

if resp.StatusCode == http.StatusFound {
url, err := resp.Location()
if err != nil {
return "", fmt.Errorf("while parsing 302 redirect url: %s", err)
}

return url.String(), nil
}
return url.String(), nil
}

return "", err
}

defer resp.Body.Close()

return "", fmt.Errorf("expected a 302 response, API returned a '%d' instead", resp.StatusCode)
}
2 changes: 1 addition & 1 deletion rest_shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// this user agent allows them to identify the client from human-generated activity.
const MailgunGoUserAgent = "mailgun-go/" + Version

// This error will be returned whenever a Mailgun API returns an error response.
// UnexpectedResponseError this error will be returned whenever a Mailgun API returns an error response.
// Your application can check the Actual field to see the actual HTTP response code returned.
// URL contains the base URL accessed, sans any query parameters.
type UnexpectedResponseError struct {
Expand Down
3 changes: 2 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package mailgun

// Version of current release
const Version = "4.6.1"
// TODO(vtopc): automate this
const Version = "4.18.5"

0 comments on commit a3a5d84

Please sign in to comment.