psu/common/printing.go
2019-08-08 11:56:07 -04:00

18 lines
332 B
Go

package common
import (
"fmt"
"os"
"strings"
"text/tabwriter"
)
func NewTabWriter(headers []string) (*tabwriter.Writer, error) {
writer := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0)
_, err := fmt.Fprintln(writer, strings.Join(headers, "\t"))
if err != nil {
return &tabwriter.Writer{}, err
}
return writer, nil
}