Golang fmt.Fprintf() function examples
**package fmt***
Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.
Golang fmt.Fprintf() function usage examples
Example 1:
func (x *Int) Format(s fmt.State, ch rune) {
cs := charset(ch)
// special cases
switch {
case cs == "":
// unknown format
fmt.Fprintf(s, "%%!%c(big.Int=%s)", ch, x.String()) //<--- here
return
case x == nil:
fmt.Fprint(s, "<nil>")
return
}
...
Example 2:
...
var helptext = `Usage: gosteno-prettify [OPTS] [FILE(s)]
Parses json formatted log lines from FILE(s), or stdin,
and displays a more human friendly version of each line to stdout.
Examples :
gosteno-prettify f - g
Prettify f's contents, then standard input, then g's contents.
gosteno-prettify
Prettify contents of stdin.
Options:
-h
Display help
-a
Omit location and data in order to provide well-aligned logs
-s
Do not complain about errors in parsing logs
`
flag.Usage = func() {
fmt.Fprintf(os.Stderr, helptext)
}
...
Reference :
Advertisement
Something interesting
Tutorials
+4.3k Golang : Issue HTTP commands to server and port example
+4k MariaDB/MySQL : Form select statement or search query with Chinese characters
+7.2k Golang : Auto-generate reply email with text/template package
+13.6k Golang : Missing Bazaar command
+10.1k Golang : How to pipe input data to executing child process?
+7.1k Golang : Reverse text lines or flip line order example
+13.6k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+10.6k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+17.9k Golang : Fix cannot download, $GOPATH not set error
+6.9k Golang Hello World Example
+6k Golang : Null and nil value
+4.9k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?