Formatted IO with fmt

One of the most widely used packages for IO is fmt (https://golang.org/pkg/fmt). It comes with an amalgam of functions designed for formatted input and output. The most common usage of the fmt package is for writing to standard output and reading from standard input. This section also highlights other functions that make fmt a great tool for IO.

Printing to io.Writer interfaces

The fmt package offers several functions designed to write text data to arbitrary implementations of io.Writer. The fmt.Fprint and fmt.Fprintln functions write text with the default format while fmt.Fprintf supports format specifiers. The following code snippet writes a columnar formatted list of metalloid data to a specified text file using the fmt.Fprintf ...

Get Go: Design Patterns for Real-World Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.