Skip to content

Commit 43b61c4

Browse files
committed
Update README.md
1 parent af1899e commit 43b61c4

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

README.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,46 @@ go get github.com/goforj/godump
5050
## 🚀 Usage
5151

5252
```go
53-
import "github.com/goforj/godump"
53+
package main
54+
55+
import (
56+
"fmt"
57+
"github.com/goforj/godump"
58+
)
5459
5560
type Profile struct {
56-
Age int
57-
Email string
61+
Age int
62+
Email string
5863
}
5964
6065
type User struct {
61-
Name string
62-
Profile Profile
66+
Name string
67+
Profile Profile
6368
}
6469
65-
user := User{
66-
Name: "Alice",
67-
Profile: Profile{
68-
Age: 30,
69-
70-
},
71-
}
70+
func main() {
71+
user := User{
72+
Name: "Alice",
73+
Profile: Profile{
74+
Age: 30,
75+
76+
},
77+
}
7278
73-
// Pretty-print to stdout
74-
godump.Dump(user)
79+
// Pretty-print to stdout
80+
godump.Dump(user)
7581
76-
// Dump and exit
77-
godump.Dd(user)
82+
// Dump and exit
83+
godump.Dd(user) // this will print the dump and exit the program
7884
79-
// Get dump as string
80-
output := godump.DumpStr(user)
85+
// Get dump as string
86+
output := godump.DumpStr(user)
87+
fmt.Println("str", output)
8188
82-
// HTML for web UI output
83-
html := godump.DumpHTML(user)
89+
// HTML for web UI output
90+
html := godump.DumpHTML(user)
91+
fmt.Println("html", html)
92+
}
8493
```
8594

8695
## 🧪 Example Output

0 commit comments

Comments
 (0)