This commit is contained in:
Mark McGranaghan 2012-10-22 17:41:33 -04:00
parent e721314b97
commit fea62fe1ed
2 changed files with 2 additions and 3 deletions

View File

@ -14,7 +14,7 @@ func main() {
// site designed to panic. // site designed to panic.
panic("a problem") panic("a problem")
// A common use of panic is to abort if function // A common use of panic is to abort if a function
// returns an error value that we don't know how to // returns an error value that we don't know how to
// (or want to) handle. Here's an example of // (or want to) handle. Here's an example of
// `panic`king if we get an unexpected error when creating a new file. // `panic`king if we get an unexpected error when creating a new file.

View File

@ -1,4 +1,4 @@
# Running the program will cause it to panic, print # Running this program will cause it to panic, print
# an error message and goroutine traces, and exit with # an error message and goroutine traces, and exit with
# a non-zero status. # a non-zero status.
$ go run panic.go $ go run panic.go
@ -13,4 +13,3 @@ exit status 2
# Note that unlike some languages which use exceptions # Note that unlike some languages which use exceptions
# for handling of many errors, in Go it is idiomatic # for handling of many errors, in Go it is idiomatic
# to use error-indicating return values wherever possible. # to use error-indicating return values wherever possible.
# We'll learn more about this in later examples.