From 53d54d1c4a7ec98ff8ddb1150c1434305a0e157a Mon Sep 17 00:00:00 2001 From: Kirill Motkov Date: Tue, 19 Mar 2019 14:19:21 +0300 Subject: [PATCH] Rewrite if-else chain to switch statement --- internal/output/prefixed.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/output/prefixed.go b/internal/output/prefixed.go index f9ea8578..0b7da89c 100644 --- a/internal/output/prefixed.go +++ b/internal/output/prefixed.go @@ -34,12 +34,12 @@ func (pw *prefixWriter) Close() error { func (pw *prefixWriter) writeOutputLines(force bool) error { for { - line, err := pw.buff.ReadString('\n') - if err == nil { + switch line, err := pw.buff.ReadString('\n'); err { + case nil: if err = pw.writeLine(line); err != nil { return err } - } else if err == io.EOF { + case io.EOF: // if this line was not a complete line, re-add to the buffer if !force && !strings.HasSuffix(line, "\n") { _, err = pw.buff.WriteString(line) @@ -47,7 +47,7 @@ func (pw *prefixWriter) writeOutputLines(force bool) error { } return pw.writeLine(line) - } else { + default: return err } }