1Columnize 2========= 3 4Easy column-formatted output for golang 5 6[![Build Status](https://travis-ci.org/ryanuber/columnize.svg)](https://travis-ci.org/ryanuber/columnize) 7[![GoDoc](https://godoc.org/github.com/ryanuber/columnize?status.svg)](https://godoc.org/github.com/ryanuber/columnize) 8 9Columnize is a really small Go package that makes building CLI's a little bit 10easier. In some CLI designs, you want to output a number similar items in a 11human-readable way with nicely aligned columns. However, figuring out how wide 12to make each column is a boring problem to solve and eats your valuable time. 13 14Here is an example: 15 16```go 17package main 18 19import ( 20 "fmt" 21 "github.com/ryanuber/columnize" 22) 23 24func main() { 25 output := []string{ 26 "Name | Gender | Age", 27 "Bob | Male | 38", 28 "Sally | Female | 26", 29 } 30 result := columnize.SimpleFormat(output) 31 fmt.Println(result) 32} 33``` 34 35As you can see, you just pass in a list of strings. And the result: 36 37``` 38Name Gender Age 39Bob Male 38 40Sally Female 26 41``` 42 43Columnize is tolerant of missing or empty fields, or even empty lines, so 44passing in extra lines for spacing should show up as you would expect. 45 46Configuration 47============= 48 49Columnize is configured using a `Config`, which can be obtained by calling the 50`DefaultConfig()` method. You can then tweak the settings in the resulting 51`Config`: 52 53``` 54config := columnize.DefaultConfig() 55config.Delim = "|" 56config.Glue = " " 57config.Prefix = "" 58config.Empty = "" 59``` 60 61* `Delim` is the string by which columns of **input** are delimited 62* `Glue` is the string by which columns of **output** are delimited 63* `Prefix` is a string by which each line of **output** is prefixed 64* `Empty` is a string used to replace blank values found in output 65 66You can then pass the `Config` in using the `Format` method (signature below) to 67have text formatted to your liking. 68 69See the [godoc](https://godoc.org/github.com/ryanuber/columnize) page for usage. 70