Files
go_playground/5-go-by-example/43-panic.go
2022-01-12 19:22:31 +01:00

17 lines
355 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import "os"
// a panic typically means something went unexpectedly wrong
func main() {
// this is the only code here designed to panic
panic("a problem")
// a common use of panic is to abort if a function returns an error value that one doesnt know how to handle
_, err := os.Create("/tmp/file")
if err != nil {
panic(err)
}
}