A Writer must be initialized with a call to Init. The first parameter (output) specifies the filter output. The remaining parameters control the formatting: minwidth minimal cell width including any padding tabwidth width of tab characters (equivalent number of spaces) padding the padding added
(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint)
| 211 | // to the tab width in the viewer displaying the result) |
| 212 | // flags formatting control |
| 213 | func (b *Writer) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer { |
| 214 | if minwidth < 0 || tabwidth < 0 || padding < 0 { |
| 215 | panic("negative minwidth, tabwidth, or padding") |
| 216 | } |
| 217 | b.output = output |
| 218 | b.minwidth = minwidth |
| 219 | b.tabwidth = tabwidth |
| 220 | b.padding = padding |
| 221 | for i := range b.padbytes { |
| 222 | b.padbytes[i] = padchar |
| 223 | } |
| 224 | if padchar == '\t' { |
| 225 | // tab padding enforces left-alignment |
| 226 | flags &^= AlignRight |
| 227 | } |
| 228 | b.flags = flags |
| 229 | |
| 230 | b.reset() |
| 231 | |
| 232 | return b |
| 233 | } |
| 234 | |
| 235 | // debugging support (keep code around) |
| 236 | func (b *Writer) dump() { |