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
+9.6k Golang : Read file with ioutil
+11.4k Golang : Delay or limit HTTP requests example
+11k Golang : Replace a parameter's value inside a configuration file example
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+21.7k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+30.4k Golang : How to redirect to new page with net/http?
+10.1k Golang : Print how to use flag for your application example
+36.3k Golang : Convert(cast) int64 to string
+9.2k Golang : How to control fmt or log print format?
+6.3k Golang : Selection sort example
+20.2k Golang : How to get own program name during runtime ?
+10.6k Golang : Flip coin example