How to print struct contents to console in Go?
Hi everyone! I just started learning Go and I'm having a debugging problem. I created a `User` struct with fields `Name`, `Age`, and `Email`. When I try to print it to the console using `fmt.Println(user)`, I see something like `{John 30 john@example.com}`, but it's not very readable. Especially when the struct is large or has nested structs.
Here's my code:
```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: "
```
No answers yet.
Log in to leave an answer
Blogs
Integration Testing PHP with Docker: A Complete Guide
Salaries of Rust Developers in Russia: Complete Market Overview 2024
Go: How to Update Third-Party Packages in 2025 — A Complete Guide
Rust for Big Data: Processing Millions of Rows Faster Than Python