Move tabwriter to package util
This offloads the "magic numbers" that are used when creating a tabwriter
This commit is contained in:
19
pkg/util/tabwriter.go
Normal file
19
pkg/util/tabwriter.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user