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
+20.7k Golang : Saving private and public key to files
+6.1k nginx : force all pages to be SSL
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+5.8k Cash Flow : 50 days to pay your credit card debt
+10.2k Golang : How to get quoted string into another string?
+14.6k Golang : Missing Bazaar command
+46.2k Golang : Read tab delimited file with encoding/csv package
+16.1k Golang : How to check if input from os.Args is integer?
+11.1k Golang : Simple image viewer with Go-GTK
+11.9k Golang : Convert(cast) bigint to string
+9.6k Javascript : Read/parse JSON data from HTTP response