In certain cases, the output (usually data output) is done via tabbed text, which is formatted in well-arranged cells. This format could be achieved with the text/tabwriter package. The package provides the Writer filter, which transforms the text with the tab characters into properly formatted output text.
Aligning text with tabwriter
How to do it...
- Open the console and create the folder chapter02/recipe05.
- Navigate to the directory.
- Create the tabwriter.go file with the following content:
package main
import (
"fmt"
"os"
"text/tabwriter"
)
func main() {
w := tabwriter.NewWriter(os.Stdout, 15, 0, 1, ' ',
...