From b595986c045c08dbf017750a81fe72f9fc72cf72 Mon Sep 17 00:00:00 2001 From: Yuki Nakamura Date: Wed, 8 Nov 2023 16:07:08 -0600 Subject: [PATCH] [exporter/influxdb] Remove //nolint indent-error-flow (#29073) I fixed linter issue by following this document. https://google.github.io/styleguide/go/decisions.html#indent-error-flow --- exporter/influxdbexporter/writer.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/exporter/influxdbexporter/writer.go b/exporter/influxdbexporter/writer.go index 4d5df9aebc49..f996ca664041 100644 --- a/exporter/influxdbexporter/writer.go +++ b/exporter/influxdbexporter/writer.go @@ -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