Skip to content
เข้าสู่ระบบ

Defer, Panic, Recover

Error handling และ cleanup mechanisms ใน Go

defer ใช้สำหรับ schedule function call ให้ทำงานเมื่อ function return

package main
import "fmt"
func main() {
defer fmt.Println("World")
fmt.Println("Hello")
}
// Output:
// Hello
// World

เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม

ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด