Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
423 B

package main
import (
"errors"
"fmt"
)
func main() {
a()
fmt.Println("This line will now get printed from main() function")
}
func a() {
b("good-bye")
fmt.Println("Back in function a()")
}
func b(msg string) {
defer func() {
if r := recover(); r != nil {
fmt.Println("error in func b()", r)
}
}()
if msg == "good-bye" {
panic(errors.New("something went wrong"))
}
fmt.Print(msg)
}