gobyexample/panic/panic.go

18 lines
225 B
Go
Raw Permalink Normal View History

2024-05-01 13:09:16 +00:00
package panic
import (
"fmt"
"os"
)
func Panic() {
p := "/cantcreate.txt"
_, err := os.Open(p)
if err != nil {
panic(fmt.Errorf("omg error when creating file %w", err))
}
fmt.Printf("%s created somehow!\n", p)
}