Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
format: simplify writeHeaders()
use strings.Join() instead of a loop
  • Loading branch information
fho committed Oct 30, 2018
1 parent 639733b commit db6de62
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions format/table/table.go
Expand Up @@ -3,6 +3,7 @@ package table
import (
"fmt"
"io"
"strings"
"text/tabwriter"
)

Expand All @@ -29,17 +30,10 @@ func New(headers []string, out io.Writer) *Formatter {
}

func (f *Formatter) writeHeader(headers []string) error {
var header string

for i, h := range headers {
header += h

if i+1 < len(headers) {
header += "\t"
}
}
header := strings.Join(headers, "\t")

_, err := fmt.Fprintln(f.tabWriter, header)

return err
}

Expand Down

0 comments on commit db6de62

Please sign in to comment.