New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text/tabwriter: AlignRight does not pad or align right-most column #14412
Comments
CC @griesemer |
Note the documentation in the tabwriter package: A Writer is a filter that inserts padding around tab-delimited columns in its input to align them in the output. (https://golang.org/pkg/text/tabwriter/) If you delimit (rather than separate) the colums with tabs it does what you want:
And the output is:
This is working as intended. Closing. |
@griesemer, thank you for clarifying. Perhaps this needs a documentation update, since the tabwriter documentation says this:
Cells can be terminated by line breaks; I'd think that the line breaks after the right-most column in my example code would have led tabwriter to interpret that last column as align-able. Should the documentation be updated to say that the cells can only be terminated by horizontal or vertical tabs? I might still be misinterpreting. |
@spenczar Fair enough. But then read further:
This is emphasized twice. That said, I agree that this does appear to contradict the former sentence. I'll update the doc. |
CL https://golang.org/cl/19855 mentions this issue. |
More clearly distinguish between tab-terminated cells which are part of an (aligned) column, and non-tab terminated cells which are not part of a column. Added additional examples. For #14412. Change-Id: If72607385752e221eaa2518238b11f48fbcb8a90 Reviewed-on: https://go-review.googlesource.com/19855 Reviewed-by: Alan Donovan <adonovan@google.com>
Thank you - I really appreciate the work on docs, boring as it may be. The examples make this sparklingly clear now. |
What did you do?
I wrote a few lines to a tabwriter with AlignRight and with padding:
What did you expect to see?
All three columns aligned right, padded with the padding rune:
What did you see instead?
The first two columns work, but the right-most column is left aligned and without padding:
Go 1.5.3 and tip (9aa630f) both exhibit this on linux/amd64.
A real-world example of output that might help show what this ends up doing:
Pretty hard to read that last column.
The text was updated successfully, but these errors were encountered: