Skip to content

Commit

Permalink
Fix lint issues and fix golangci-lint version
Browse files Browse the repository at this point in the history
  • Loading branch information
SkYNewZ committed Oct 11, 2022
1 parent bbedc5e commit ed4987b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0

build:
runs-on: ubuntu-latest
Expand Down
23 changes: 8 additions & 15 deletions internal/putio/putio.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ func (s *rssService) List(ctx context.Context) ([]*Feed, error) {
if err != nil {
return nil, fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)

var r struct {
Feeds []*Feed `json:"feeds"`
}
_, err = s.client.Do(req, &r) //nolint:bodyclose,contextcheck
_, err = s.client.Do(req, &r) //nolint:bodyclose
if err != nil {
return nil, fmt.Errorf("putio: response error: %w", err)
}

return r.Feeds, nil
}

// Get a RSS feed.
// Get an RSS feed.
func (s *rssService) Get(ctx context.Context, id uint) (*Feed, error) {
ctx, span := s.client.tracer.Start(ctx, "putio.rssService.Get")
defer span.End()
Expand All @@ -71,12 +70,11 @@ func (s *rssService) Get(ctx context.Context, id uint) (*Feed, error) {
if err != nil {
return nil, fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)

var r struct {
Feed *Feed `json:"feed"`
}
_, err = s.client.Do(req, &r) //nolint:bodyclose,contextcheck
_, err = s.client.Do(req, &r) //nolint:bodyclose
if err != nil {
return nil, fmt.Errorf("putio: response error: %w", err)
}
Expand All @@ -95,9 +93,8 @@ func (s *rssService) Delete(ctx context.Context, id uint) error {
if err != nil {
return fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)

_, err = s.client.Do(req, nil) //nolint:bodyclose,contextcheck
_, err = s.client.Do(req, nil) //nolint:bodyclose
if err != nil {
return fmt.Errorf("putio: response error: %w", err)
}
Expand All @@ -124,13 +121,12 @@ func (s *rssService) Create(ctx context.Context, feed *Feed) (*Feed, error) {
if err != nil {
return nil, fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

var r struct {
Feed *Feed `json:"feed"`
}
_, err = s.client.Do(req, &r) //nolint:bodyclose,contextcheck
_, err = s.client.Do(req, &r) //nolint:bodyclose
if err != nil {
return nil, fmt.Errorf("putio: response error: %w", err)
}
Expand Down Expand Up @@ -158,14 +154,13 @@ func (s *rssService) Update(ctx context.Context, feed *Feed, id uint) error {
if err != nil {
return fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

var r struct {
Status string `json:"status"`
}

if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose,contextcheck
if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose
return fmt.Errorf("putio: response error: %w", err)
}

Expand All @@ -187,13 +182,12 @@ func (s *rssService) Pause(ctx context.Context, id uint) error {
if err != nil {
return fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)

var r struct {
Status string `json:"status"`
}

if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose,contextcheck
if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose
return fmt.Errorf("putio: response error: %w", err)
}

Expand All @@ -215,13 +209,12 @@ func (s *rssService) Resume(ctx context.Context, id uint) error {
if err != nil {
return fmt.Errorf("putio: cannot make request: %w", err)
}
*req = *req.WithContext(ctx)

var r struct {
Status string `json:"status"`
}

if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose,contextcheck
if _, err := s.client.Do(req, &r); err != nil { //nolint:bodyclose
return fmt.Errorf("putio: response error: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/putio/putio_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed4987b

Please sign in to comment.