From 5ccb031db397775520f4c96753b623fd70142614 Mon Sep 17 00:00:00 2001 From: Michael Woolnough Date: Mon, 28 Oct 2024 10:46:14 +0000 Subject: [PATCH] Delint'd. --- cmd/decode.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/decode.go b/cmd/decode.go index 70a1172d..f24c6bf1 100644 --- a/cmd/decode.go +++ b/cmd/decode.go @@ -38,6 +38,11 @@ import ( "github.com/wtsi-ssg/wrstat/v5/internal/encode" ) +const ( + statsColumn = 0 + byUserGroupColumn = 2 +) + // chtsvCmd represents the chtsv command. var decodeCmd = &cobra.Command{ Use: "decode", @@ -52,7 +57,7 @@ Files with names ending in '.gz' will be decompressed before printing. Other files are simply copied to stdout. `, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { for _, file := range args { if err := decodeFile(file); err != nil { die("%s", err) @@ -88,8 +93,10 @@ func decodeFile(file string) error { var col int if strings.HasSuffix(file, ".byusergroup") { - col = 2 - } else if !strings.HasSuffix(file, ".stats") { + col = byUserGroupColumn + } else if strings.HasSuffix(file, ".stats") { + col = statsColumn + } else { _, err = io.Copy(os.Stdout, r) return err @@ -115,7 +122,9 @@ func decodeColumn(r io.Reader, col int) error { } if line == "\n" { - w.WriteString(line) + if _, err := w.WriteString(line); err != nil { + return err + } continue }