Skip to content

mertenvg/grok

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grok it like you mean it!

Tired of debugging using fmt.Println and fmt.Printf("%+v", var). Use grok to print out a pretty formatted view of your variables and what's in them.

Install:

go get github.com/mertenvg/grok@latest

Usage:

grok.V(myVar) // or grok.Value(myVar)

// or for customised output

grok.V(myVar, grok.WithMaxDepth(3), grok.WithTabStop(2))

The grok package comes with the following customisation options baked in:

// WithWriter redirects output from debug functions to the given io.Writer
func WithWriter(w io.Writer) Option
// WithoutColours disables colouring of output from debug functions. Defaults to `true`
func WithoutColours() Option
// WithMaxDepth sets the maximum recursion depth from debug functions. Defaults to `10`, use `0` for unlimited
func WithMaxDepth(depth int) Option 
// WithMaxLength sets the maximum length of string values. Default is `100`, use `0` for unlimited
func WithMaxLength(chars int) Option
// WithTabStop sets the width of a tabstop to the given char count. Defaults to `4`
func WithTabStop(chars int) Option

Abbreviated types

The following go types have their output abbreviated when nested within other structs. To see their un-abbreviated content simply grok.V that specific value.

time.Time
http.Request
http.Response

Got 99 problems and this code is one?

Please create an issue

About

Pretty output of your Go variables so you can Grok your code like a pro

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages