Golang go/scanner.PrintError() function examples
package go/scanner
PrintError is a utility function that prints a list of errors to w(1st parameter), one error per line, if the err parameter is an ErrorList. Otherwise it prints the err(2nd parameter) string.
Golang go/scanner.PrintError() function usage examples
Example 1:
if p, err := processFile(filename); err != nil {
log.Printf("\t%s\n\n", filename)
scanner.PrintError(os.Stderr, err) // <-- here
exitCode = 1
}
Example 2:
if len(list) != 9 {
t.Errorf("found %d sorted errors, expected 9", len(list))
PrintError(os.Stderr, list)
}
Reference :
Advertisement
Something interesting
Tutorials
+7.7k Golang : Mapping Iban to Dunging alphabets
+14.4k Golang : Recombine chunked files example
+16.9k Golang : How to generate QR codes?
+18.5k Golang : Send email with attachment
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+6.6k Golang : Totalize or add-up an array or slice example
+13.8k Generate salted password with OpenSSL example
+5.6k Unix/Linux : How to find out the hard disk size?
+5.8k Cash Flow : 50 days to pay your credit card debt
+17.5k Golang : Find smallest number in array
+5.6k Python : Print unicode escape characters and string
+5.9k Golang : Shuffle array of list