cristaloleg / dbg

Debug helpers for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dbg

build-img pkg-img reportcard-img coverage-img version-img

Debug helpers for Go.

Acknowledge

Thanks to Bohdan Storozhuk for storozhukBM/dump which inspired dbg.Dump.

Features

  • Simple.
  • Useful.
  • Really helps.

See these docs or GUIDE.md for more details.

Install

Go version 1.19+

go get github.com/cristaloleg/dbg

Example

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.

License

MIT License.

About

Debug helpers for Go

License:MIT License


Languages

Language:Go 100.0%