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
+22.2k Golang : Securing password with salt
+37.5k Upload multiple files with Go
+4.6k Mac OSX : Get disk partitions' size, type and name
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+9.6k Golang : Read file with ioutil
+7.6k Golang : Convert(cast) io.Reader type to string
+39k Golang : How to iterate over a []string(array)
+6.2k Golang & Javascript : How to save cropped image to file on server
+14k Golang : Reverse IP address for reverse DNS lookup example
+7.2k Golang : Null and nil value
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format