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
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+16.4k CodeIgniter/PHP : Create directory if does not exist example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+29.9k Golang : How to get HTTP request header information?
+9.4k Golang : Web(Javascript) to server-side websocket example
+14.9k Golang : Submit web forms without browser by http.PostForm example
+6.5k Golang : Map within a map example
+9.7k Golang : Populate slice with sequential integers example
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+12.2k Golang : Split strings into command line arguments
+10.1k Golang : Print how to use flag for your application example
+25.8k Golang : Daemonizing a simple web server process example