Go में struct की सामग्री को कंसोल में कैसे प्रिंट करें?
सभी को नमस्कार! मैंने अभी-अभी Go सीखना शुरू किया है, और मुझे डीबगिंग में एक समस्या आ रही है। मैंने एक `User` स्ट्रक्चर बनाया है, जिसमें `Name`, `Age` और `Email` फील्ड्स हैं। जब मैं इसे `fmt.Println(user)` के माध्यम से कंसोल में प्रिंट करने की कोशिश करता हूँ, तो मुझे कुछ इस तरह दिखता है `{John 30 john@example.com}`, लेकिन यह बहुत पढ़ने योग्य नहीं है। खासकर जब स्ट्रक्चर बड़ा हो या उसमें नेस्टेड स्ट्रक्चर हों।
यहाँ मेरा कोड है:
```go
package main
import "fmt"
type Address struct {
City string
Street string
ZipCode int
}
type User struct {
Name string
Age int
Email string
Address Address
}
func main() {
user := User{
Name: "John Doe",
Age: 30,
Email: "john@example.com",
Address: Address{
City: "New York",
Street: "5th Avenue",
ZipCode: 10001,
},
}
fmt.Println(user) // आउटपुट: {John Doe 30 john@example.com {New York 5th Avenue 10001}}
}
```
मैं फील्ड नाम देखना चाहता हूँ और