Golang fmt.Printf() function examples

package fmt.Printf

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

Golang fmt.Printf() function usage examples

Example 1:

 fmt.Printf("Connected to ver=%s\n", c.Info.ImplementationVersion)

Example 2:

 fmt.Printf("Found pool:  %s -> %s\n", pn.Name, pn.URI)

Example 3:

 m := make(chan request)
 go runMap(m)

 fmt.Printf("Set %s\n", set(m, 1, "foo"))
 fmt.Printf("Set %s\n", set(m, 2, "hoge"))
 fmt.Printf("Set %s\n", set(m, 1, "fuga"))
 fmt.Printf("Set %s\n", set(m, 2, "bar"))

Reference :

http://golang.org/pkg/fmt/#Printf

Advertisement