GO by example, part 5

This commit is contained in:
2022-01-12 19:22:31 +01:00
parent 5d7e654fa1
commit a7d96f5106
10 changed files with 488 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
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)
}
}