![Go Standard Library Cookbook](https://wfqqreader-1252317822.image.myqcloud.com/cover/179/36700179/b_36700179.jpg)
上QQ阅读APP看书,第一时间看更新
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, ' ',
tabwriter.AlignRight)
fmt.Fprintln(w, "username\tfirstname\tlastname\t")
fmt.Fprintln(w, "sohlich\tRadomir\tSohlich\t")
fmt.Fprintln(w, "novak\tJohn\tSmith\t")
w.Flush()
}
- Run the code by executing go run tabwriter.go.
- See the output in the Terminal:
![](https://epubservercos.yuewen.com/D3CFF8/19470397101585106/epubprivate/OEBPS/Images/b82420b6-4610-4dc0-a2c5-c60ce2564e0c.png?sign=1739584142-cDtZkSs2RSli7mE2a28WT0RSEfZCxNoD-0-8f30d899248d7907d848bf46197b646a)