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
+19.6k Golang : Get current URL example
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+5.2k Golang : Print instead of building pyramids
+7.5k Golang : Handling Yes No Quit query input
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+37.5k Golang : Converting a negative number to positive number
+5k Google : Block or disable caching of your website content
+4.4k Linux/MacOSX : Search and delete files by extension
+6.1k nginx : force all pages to be SSL
+10.8k Android Studio : Checkbox for user to select options example
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+24.1k Golang : Upload to S3 with official aws-sdk-go package