GODUMP is a powerful Go library that elegantly formats any Go variable, providing well-structured and colored output that's perfect for debugging and logging. Unlike the standard fmt library, GODUMP enhances visibility into complex data types, including unexported fields and recursive pointers, making it an essential tool for developers seeking clarity in their code.
godump is a powerful Go library that simplifies the process of dumping any Go variable into a structured and visually appealing format. Ideal for developers dealing with complex data structures, godump enhances debugging and testing experiences by providing a more effective representation of data than the standard fmt package can offer.
Start using godump with minimal setup:
package main
import (
"github.com/yassinebenaid/godump"
)
func main() {
godump.Dump("Anything")
}
For more control over the output, utilize the Dumper:
package main
import (
"os"
"github.com/yassinebenaid/godump"
)
func main() {
var v = "Foo Bar"
var d = godump.Dumper{
Indentation: " ",
HidePrivateFields: false,
ShowPrimitiveNamedTypes: false,
Theme: godump.Theme{
String: godump.RGB{R: 138, G: 201, B: 38},
// Configure other themes as necessary
},
}
d.Print(v)
d.Println(v)
d.Fprint(os.Stdout, v)
d.Fprintln(os.Stdout, v)
d.Sprint(v)
d.Sprintln(v)
}
Check out various examples that illustrate the capabilities of godump:
package main
import (
"os"
"github.com/yassinebenaid/godump"
)
func main() {
godump.Dump(os.Stdout)
}
package main
import (
"github.com/yassinebenaid/godump"
)
func main() {
type User struct {
Name string
age int
BestFriend *User
}
me := User{Name: "yassinebenaid", age: 22}
me.BestFriend = &me
godump.Dump(me)
}
package main
import (
"fmt"
"net"
"net/http"
"github.com/yassinebenaid/godump"
)
func main() {
var d godump.Dumper
d.Theme = godump.Theme{
String: CSSColor{138, 201, 38},
// Define other colors as per the theme
}
var html = `<pre style="background: #111; padding: 10px; color: white">`
html += d.Sprint(net.Dialer{})
html += "<pre>"
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
fmt.Fprint(w, html)
})
http.ListenAndServe(":8000", nil)
}
For further insights and contributions, please refer to the CONTRIBUTING guidelines available in the repository.
Explore godump to transform the way you handle and log Go variables with style and clarity!
No comments yet.
Sign in to be the first to comment.