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

Debugging

Go มีเครื่องมือหลายอย่างสำหรับ debugging: print, delve, pprof

package main
import (
"fmt"
"log"
)
type User struct {
ID int
Name string
Email string
}
func processUser(u User) {
// Simple print
fmt.Printf("Processing user: %+v\n", u)
// With log (includes timestamp)
log.Printf("User ID: %d, Name: %s\n", u.ID, u.Name)
// Debug format - shows Go syntax
fmt.Printf("Debug: %#v\n", u)
// Type information
fmt.Printf("Type: %T\n", u)
}
func main() {
user := User{ID: 1, Name: "สมชาย", Email: "s@mail.com"}
processUser(user)
}

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

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