From 7bb92dec2f764a678cf55b3165131de85fd6028a Mon Sep 17 00:00:00 2001 From: Lee Marlow Date: Fri, 4 Nov 2022 18:04:21 -0600 Subject: [PATCH] Set writer.Comma in same manner as reader.Comma Fix linting issue with ignoring an error --- table/command.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/table/command.go b/table/command.go index bdd774c..285c2ac 100644 --- a/table/command.go +++ b/table/command.go @@ -36,6 +36,9 @@ func (o Options) Run() error { } reader.Comma = separatorRunes[0] + writer := csv.NewWriter(os.Stdout) + writer.Comma = separatorRunes[0] + var columnNames []string var err error // If no columns are provided we'll use the first row of the CSV as the @@ -102,10 +105,12 @@ func (o Options) Run() error { m := tm.(model) - w := csv.NewWriter(os.Stdout) - w.Comma = reader.Comma - w.Write([]string(m.selected)) - w.Flush() + err = writer.Write([]string(m.selected)) + if err != nil { + return fmt.Errorf("failed to write selected row: %w", err) + } + + writer.Flush() return nil }