diff --git a/main.go b/main.go index a21c216..eb1a714 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,8 @@ package main // import "git.sangeeth.dev/gobyexample/atomics" // import "git.sangeeth.dev/gobyexample/mutex" // import "git.sangeeth.dev/gobyexample/statefulgoroutines" -import "git.sangeeth.dev/gobyexample/sorting" +// import "git.sangeeth.dev/gobyexample/sorting" +import "git.sangeeth.dev/gobyexample/panic" func main() { // runes.Runes() @@ -39,5 +40,6 @@ func main() { // atomics.Atomics() // mutex.Mutex() // statefulgoroutines.StatefulGoroutines() - sorting.Sorting() + // sorting.Sorting() + panic.Panic() } diff --git a/panic/panic.go b/panic/panic.go new file mode 100644 index 0000000..270e896 --- /dev/null +++ b/panic/panic.go @@ -0,0 +1,17 @@ +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) +}