Skip to content

Replace manual loops with copy() in internal/tui/tables.go #9

@jadb

Description

@jadb

Problem

staticcheck S1001 at internal/tui/tables.go:20 and :32 — manual element-by-element loops should use copy().

Fix

 func NewTable(headers []interface{}) *Table {
     t := table.NewWriter()
     t.SetOutputMirror(os.Stdout)

     row := make(table.Row, len(headers))
-    for i, h := range headers {
-        row[i] = h
-    }
+    copy(row, headers)
     t.AppendHeader(row)

 func (t *Table) AddRow(row ...interface{}) {
     r := make(table.Row, len(row))
-    for i, v := range row {
-        r[i] = v
-    }
+    copy(r, row)
     t.t.AppendRow(r)
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions