davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.98k stars 361 forks source link

feat (DisableFunctionTypePointerAddresses) fields of type func.. abil… #104

Closed pentateu closed 5 years ago

pentateu commented 5 years ago

Added DisableFunctionTypePointerAddresses to config.

If true it will not print the address of a Func field.

Example: type someFuncType func(string) string type someStructType struct { funcField someFuncType }

before this PR this would print: (*spew_test.ptrFuncTester)({ funcField: (spew_test.someFuncType) 0x11a49b0 })

With this PR and DisableFunctionTypePointerAddresses = true it will print: (*spew_test.ptrFuncTester)({ funcField: (spew_test.someFuncType) })

This is important for snapshot testing, which is my use case.

Cheers

pentateu commented 5 years ago

PS: I could not find a way to fix that for the Fprint also.. This only works for the Dump functions, which is what is required in my case.

pentateu commented 5 years ago

wrong branch :( .. deleting PR.

pentateu commented 5 years ago

Created 105 instead --> https://github.com/davecgh/go-spew/pull/105