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
+6.1k Golang : Dealing with backquote
+8.1k Golang : Randomize letters from a string example
+12.4k Golang : Extract part of string with regular expression
+6.5k Golang : Combine slices of complex numbers and operation example
+14.4k Golang : How to convert a number to words
+15.6k Golang : How to convert(cast) IP address to string?
+12.1k Golang : Decompress zlib file example
+5.3k Javascript : Shuffle or randomize array example
+4.3k Javascript : How to show different content with noscript?
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+10.2k Golang : Find and replace data in all files recursively
+14.3k Golang : How to shuffle elements in array or slice?