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.4k JavaScript : Rounding number to decimal formats to display currency
+15.8k Golang : Loop each day of the current month example
+11.8k Golang : Save webcamera frames to video file
+17.1k Golang : Linked list example
+8.4k Golang : How to join strings?
+13.2k Golang : Get user input until a command or receive a word to stop
+6.1k PHP : Proper way to get UTF-8 character or string length
+7.9k Golang : HTTP Server Example
+8.5k Golang : On lambda, anonymous, inline functions and function literals
+7.6k Golang : Gomobile init produce "iphoneos" cannot be located error
+30.5k error: trying to remove "yum", which is protected