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
+17.6k Golang : delete and modify XML file content
+22.3k Golang : Read directory content with filepath.Walk()
+8k Golang : Get all countries phone codes
+21.3k Golang : Create and resolve(read) symbolic links
+11.2k Golang : How to pipe input data to executing child process?
+8.2k Android Studio : Rating bar example
+6.1k Golang : Grab news article text and use NLP to get each paragraph's sentences
+11.6k Swift : Convert (cast) Float to String
+6.8k Golang : Find the longest line of text example
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+11.3k Golang : Characters limiter example
+7.5k Golang : Handling Yes No Quit query input