HuangTing-Yao commented on code in PR #236:
URL: https://github.com/apache/yunikorn-release/pull/236#discussion_r3713329597
##########
perf-tools/utils/table.go:
##########
@@ -46,9 +47,13 @@ func (t *Table) Output(file string) error {
}
func (t *Table) render(writer *tablewriter.Table) {
Review Comment:
NIT:
We might need to propagate the error of `render()`, otherwise it might lose
in `Output()`. Also need to adjust `Print()` to fit `golangci-lint`'s
`errcheck`.
Please refer below.
```suggestion
func (t *Table) render(writer *tablewriter.Table) error {
writer.Header(t.Headers)
for _, v := range t.Data {
if err := writer.Append(v); err != nil {
return err
}
}
return writer.Render()
}
func (t *Table) Print() {
writer := tablewriter.NewWriter(os.Stdout)
if err := t.render(writer); err != nil {
Logger.Error("failed to render table to stdout", zap.Error(err))
}
}
func (t *Table) Output(file string) error {
f, err := os.Create(file)
if err != nil {
return err
}
defer f.Close() // also fixes a pre-existing leak
return t.render(tablewriter.NewWriter(f))
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]