From a121e978f7ddf85ec44f2b1780569f094562ba9c Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 31 May 2016 16:00:14 -0700 Subject: [PATCH] Switch "printHelp" tabwriter padchar to space Using tabs for alignment is troubling if the output is used for anything besides display in a terminal (or if the user's terminal allows for adjustment of the default tab size), as noted by the documentation for `tabwriter` (https://golang.org/pkg/text/tabwriter/#Writer.Init): > (for correct-looking results, tabwidth must correspond to the tab width in the viewer displaying the result) The safer solution is to use `' '` as the `padchar`, which only carries the assumption of a fixed-width font (which is a more reasonable assumption than a fixed, constant tab size). --- help.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help.go b/help.go index a9e7327..f2ddc54 100644 --- a/help.go +++ b/help.go @@ -191,7 +191,7 @@ func printHelp(out io.Writer, templ string, data interface{}) { "join": strings.Join, } - w := tabwriter.NewWriter(out, 0, 8, 1, '\t', 0) + w := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0) t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) err := t.Execute(w, data) if err != nil {