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
+6.3k Golang : Selection sort example
+40.1k Golang : UDP client server read write example
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+8.8k Golang : Random integer with rand.Seed() within a given range
+10.1k Golang : Edge detection with Sobel method
+8.2k Golang : Add build version and other information in executables
+6.9k Nginx : Password protect a directory/folder
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+7.3k Golang : Not able to grep log.Println() output
+5.4k How to check with curl if my website or the asset is gzipped ?
+6.9k How to let Facebook Login button redirect to a particular URL ?