Move tabwriter to package util

This offloads the "magic numbers" that are used when creating a
tabwriter
This commit is contained in:
Ian Howell
2019-05-23 15:24:56 -05:00
parent 33fecc360b
commit be2a61047c
2 changed files with 21 additions and 2 deletions

19
pkg/util/tabwriter.go Normal file
View File

@@ -0,0 +1,19 @@
package util
import (
"io"
"text/tabwriter"
)
const (
tabwriterMinWidth = 6
tabwriterWidth = 4
tabwriterPadding = 3
tabwriterPadChar = ' '
tabwriterFlags = 0
)
// NewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
func NewTabWriter(out io.Writer) *tabwriter.Writer {
return tabwriter.NewWriter(out, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterFlags)
}