Conditions | 6 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package csv |
||
30 | func (c *csvExport) Export() error { |
||
31 | if err := c.loadColumns(); err != nil { |
||
32 | return fmt.Errorf("failed to load columns: %w", err) |
||
1 ignored issue
–
show
|
|||
33 | } |
||
34 | |||
35 | if err := c.openFile(); err != nil { |
||
36 | return fmt.Errorf("failed to open file: %w", err) |
||
1 ignored issue
–
show
|
|||
37 | } |
||
38 | |||
39 | w := csv.NewWriter(c.file) |
||
40 | defer w.Flush() |
||
41 | |||
42 | if err := w.Write(c.columns); err != nil { |
||
43 | return fmt.Errorf("failed to write headers: %w", err) |
||
1 ignored issue
–
show
|
|||
44 | } |
||
45 | |||
46 | for c.rows.Next() { |
||
47 | _ = c.bar.Add(1) |
||
48 | if err := c.readAndAppendFile(w); err != nil { |
||
49 | return fmt.Errorf("failed to read and append line in file: %w", err) |
||
1 ignored issue
–
show
|
|||
50 | } |
||
51 | } |
||
52 | |||
53 | return nil |
||
54 | } |
||
128 |