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.
 

28 lines
411 B

package main
import (
"errors"
"fmt"
)
func main() {
test()
fmt.Println("This line will not get printed")
}
func test() {
n := func() {
fmt.Println("Defer in test")
}
defer n()
msg := "good-bye"
message(msg)
}
func message(msg string) {
f := func() {
fmt.Println("Defer in message func")
}
defer f()
if msg == "good-bye" {
panic(errors.New("something went wrong"))
}
}