Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jul 13, 2024
1 parent 1ed64c6 commit 403cd51
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var csvCmd = &cobra.Command{
baseURL := fmt.Sprintf("%s/node/%s?_format=workbench_csv", baseUrl, nid)

var allHeaders []string
var err error
headerMap := make(map[string]bool)
rows := []Row{}
nodeIDMap := make(map[string]bool)
Expand Down Expand Up @@ -136,14 +137,22 @@ var csvCmd = &cobra.Command{
csvWriter := csv.NewWriter(outFile)
defer csvWriter.Flush()

csvWriter.Write(allHeaders)
err = csvWriter.Write(allHeaders)
if err != nil {
slog.Error("Unable to write to CSV", "err", err)
os.Exit(1)
}

for _, row := range rows {
record := make([]string, len(allHeaders))
for i, header := range allHeaders {
record[i] = row[header]
}
csvWriter.Write(record)
err = csvWriter.Write(record)
if err != nil {
slog.Error("Unable to write to CSV", "err", err)
os.Exit(1)
}
}

fmt.Println("CSV files merged successfully into", csvFile)
Expand Down

0 comments on commit 403cd51

Please sign in to comment.