Skip to content

Commit

Permalink
🚨 Fix funlen
Browse files Browse the repository at this point in the history
  • Loading branch information
nkmr-jp committed Jul 23, 2022
1 parent 07bef4e commit fd938c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,13 @@ func Fetch(ctx context.Context, event event.Event) error {
return nil
}

// nolint:funlen
func get(urlStr string) *bytes.Buffer {
u, err := nu.Parse(urlStr)
if err != nil {
return nil
}
res, err := http.Get(u.String())
if res.StatusCode != http.StatusOK {
zl.Error("HTTP_GET_ERROR", fmt.Errorf("status code is %d", res.StatusCode))
return nil
}

defer func() {
if err := res.Body.Close(); err != nil {
zl.Error("HTTP_CLOSE_ERROR", err)
Expand All @@ -93,6 +89,10 @@ func get(urlStr string) *bytes.Buffer {
zl.Error("HTTP_GET_ERROR", err)
return nil
}
if res.StatusCode != http.StatusOK {
zl.Error("HTTP_GET_ERROR", fmt.Errorf("status code is %d", res.StatusCode))
return nil
}

ret, err := io.ReadAll(res.Body)
if err != nil {
Expand Down

0 comments on commit fd938c4

Please sign in to comment.