Skip to content

Commit

Permalink
style: use Transformer comma separate
Browse files Browse the repository at this point in the history
  • Loading branch information
yanskun committed May 9, 2024
1 parent d6a5f63 commit fd4d261
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,23 @@ func printTable(languages Languages) {
{
Name: "Lines",
Align: text.AlignRight,
Transformer: func(val interface{}) string {
return p.Sprintf("%d", val)
},
TransformerFooter: func(val interface{}) string {
return p.Sprintf("%d", val)
},
},
})

// Append rows in sorted order
sumLines := 0
for _, pair := range pairs {
num := p.Sprintf("%d", pair.Value)
t.AppendRow(table.Row{pair.Key, num})
sumLines += pair.Value
t.AppendRow(table.Row{pair.Key, pair.Value})
}

t.AppendFooter(table.Row{"Total", sumLines})
t.Render()
}

Expand Down

0 comments on commit fd4d261

Please sign in to comment.