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
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+21.2k Golang : How to get time zone and load different time zone?
+8.1k Golang : Variadic function arguments sanity check example
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+8.3k Golang: Prevent over writing file with md5 hash
+9.4k Golang : Apply Histogram Equalization to color images
+9.4k Golang : Play .WAV file from command line
+20.9k Golang : Underscore or snake_case to camel case example
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+11.3k Golang : How to use if, eq and print properly in html template
+25.3k Golang : Get current file path of a file or executable