Skip to content

Commit

Permalink
[exporter/influxdb] Remove //nolint indent-error-flow (#29073)
Browse files Browse the repository at this point in the history
I fixed linter issue by following this document.
https://google.github.io/styleguide/go/decisions.html#indent-error-flow
  • Loading branch information
yukinakanaka authored Nov 8, 2023
1 parent c95d613 commit b595986
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions exporter/influxdbexporter/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,24 @@ func (b *influxHTTPWriterBatch) WriteBatch(ctx context.Context) error {
return consumererror.NewPermanent(err)
}

if res, err := b.httpClient.Do(req); err != nil {
res, err := b.httpClient.Do(req)
if err != nil {
return err
} else if body, err := io.ReadAll(res.Body); err != nil {
}
body, err := io.ReadAll(res.Body)
if err != nil {
return err
} else if err = res.Body.Close(); err != nil {
}
if err = res.Body.Close(); err != nil {
return err
} else { // nolint indent-error-flow
switch res.StatusCode / 100 {
case 2: // Success
break
case 5: // Retryable error
return fmt.Errorf("line protocol write returned %q %q", res.Status, string(body))
default: // Terminal error
return consumererror.NewPermanent(fmt.Errorf("line protocol write returned %q %q", res.Status, string(body)))
}
}
switch res.StatusCode / 100 {
case 2: // Success
break
case 5: // Retryable error
return fmt.Errorf("line protocol write returned %q %q", res.Status, string(body))
default: // Terminal error
return consumererror.NewPermanent(fmt.Errorf("line protocol write returned %q %q", res.Status, string(body)))
}

return nil
Expand Down

0 comments on commit b595986

Please sign in to comment.