2024-01-24 10:17:42 +00:00
|
|
|
|
2024-01-24 03:22:02 +00:00
|
|
|
package defer_statement
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
func A() {
|
|
|
|
fmt.Println("A function worked")
|
|
|
|
}
|
|
|
|
|
2024-01-24 03:33:36 +00:00
|
|
|
func C() {
|
|
|
|
fmt.Println("C function worked")
|
|
|
|
}
|
|
|
|
|
|
|
|
func D() {
|
|
|
|
fmt.Println("D function worked")
|
|
|
|
}
|
|
|
|
|
2024-01-24 03:22:02 +00:00
|
|
|
func B() {
|
2024-01-24 03:26:29 +00:00
|
|
|
defer A()
|
2024-01-24 03:33:36 +00:00
|
|
|
defer C()
|
|
|
|
defer D()
|
2024-01-24 03:22:02 +00:00
|
|
|
fmt.Println("B function worked")
|
|
|
|
}
|
|
|
|
|
2024-01-24 03:33:36 +00:00
|
|
|
|