Created
July 10, 2014 16:33
-
-
Save jordanorelli/4aa9fffafb0ba10ce2ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
err := fmt.Errorf("this is an error.") | |
// these two lines print the same thing when err is non-nil | |
fmt.Printf("%v\n", err) | |
fmt.Printf("%s\n", err.Error()) | |
err = nil | |
fmt.Printf("%v\n", err) // this is safe | |
fmt.Printf("%s\n", err.Error()) // this is a panic | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment