-
Notifications
You must be signed in to change notification settings - Fork 7
Library Usage
guitarbum722 edited this page Sep 10, 2017
·
3 revisions
NewAlign creates and initializes a ScanWriter with in and out as its initial Reader and Writer and sets del to the desired delimiter to be used for alignment. It is meant to read the contents of its io.Reader to determine the length of each field and output the results in an aligned format. Left Justification is used by default. See UpdatePadding to set the Justification.
input := strings.NewReader("first,middle,last")
output := bytes.NewBufferString("")
aligner := align.NewAlign(input, output, ",", "\"") // io.Reader, io.Writer, input delimiter, text qualifierUse the PaddingOpts type to configure padding related output.
aligner.UpdatePadding(
align.PaddingOpts{
Justification: align.JustifyCenter,
ColumnOverride: map[int]Justification{
2: align.JustifyRight,
3: align.JustifyLeft,
},
Pad: 3, // default is 1
}
)aligner.FilterColumns([]int{3,4,7,10}]) // indexed starting with 1aligner.OutputSep("|")aligner.Align()