Golang fmt.GoStringer type example
package fmt
GoStringer is implemented by any value that has a GoString method, which defines the Go syntax for that value. The GoString method is used to print values passed as an operand to a %#v format.
Golang fmt.GoStringer type usage example
func deepPrint(b *bytes.Buffer, v reflect.Value) {
i := v.Interface()
t := v.Type()
// GoStringer
if g, ok := i.(fmt.GoStringer); ok {
b.WriteString(g.GoString())
return
}
...
Reference :
Advertisement
Something interesting
Tutorials
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+26.8k Golang : Convert file content into array of bytes
+7.5k Golang : How to handle file size larger than available memory panic issue
+6.9k Golang : Calculate BMI and risk category
+10.2k Golang : How to profile or log time spend on execution?
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+9k Golang : Get SPF and DMARC from email headers to fight spam
+7.9k Golang : Trim everything onward after a word
+9.4k Golang : Play .WAV file from command line
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+10.1k Golang : How to tokenize source code with text/scanner package?
+4.7k Golang : How to pass data between controllers with JSON Web Token