Debug helpers for Go
MIT License
Debug helpers for Go.
Thanks to Bohdan Storozhuk for storozhukBM/dump which inspired dbg.Dump
.
See these docs or GUIDE.md for more details.
Go version 1.19+
go get github.com/cristaloleg/dbg
func main() {
dbg.Hit() // count how many times this line was executed
dbg.PrintOnce("debuging") // print once per program run
for i := 0; i < 1000; i++ {
// +1 every 10 calls
dbg.Every(10, func(count int64) { counter++ })
}
x := 123
str := "striiiing"
dbg.Dump("so far we have ", x, str)
// will be printed:
// so far we have x: `123`; str: `striiiing`
}
See examples: example_test.go.