Add panic
This commit is contained in:
parent
b2314b5f63
commit
36574bafdf
6
main.go
6
main.go
@ -18,7 +18,8 @@ package main
|
|||||||
// import "git.sangeeth.dev/gobyexample/atomics"
|
// import "git.sangeeth.dev/gobyexample/atomics"
|
||||||
// import "git.sangeeth.dev/gobyexample/mutex"
|
// import "git.sangeeth.dev/gobyexample/mutex"
|
||||||
// import "git.sangeeth.dev/gobyexample/statefulgoroutines"
|
// 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() {
|
func main() {
|
||||||
// runes.Runes()
|
// runes.Runes()
|
||||||
@ -39,5 +40,6 @@ func main() {
|
|||||||
// atomics.Atomics()
|
// atomics.Atomics()
|
||||||
// mutex.Mutex()
|
// mutex.Mutex()
|
||||||
// statefulgoroutines.StatefulGoroutines()
|
// statefulgoroutines.StatefulGoroutines()
|
||||||
sorting.Sorting()
|
// sorting.Sorting()
|
||||||
|
panic.Panic()
|
||||||
}
|
}
|
||||||
|
17
panic/panic.go
Normal file
17
panic/panic.go
Normal file
@ -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)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user