On Fri, Sep 4, 2020 at 1:11 PM [email protected] <[email protected]> wrote:
>
> Often on my team, Go programmers (particularly new ones) simply want full
> visibility into a data structure when debugging. For those who aren't
> familiar with pointers, seeing a hexadecimal number show up in a log can be
> really frustrating. I usually point them to
> https://github.com/davecgh/go-spew or https://github.com/sanity-io/litter.
> Although they can be heavy-handed with their unsafe package dependency and
> fancy formatting, they are indispensable when debugging data structures like
> syntax trees.
>
> I wonder it's worthwhile to add this functionality to the reflect package,
> and take advantage of the functionality that DeepEquals uses. I'm not a fan
> of Dump functions that just take an io.Writer. Why not add a named type for
> interface{} or reflect.Value called reflect.Deep, which implements
> fmt.Formatter? Then, packages that use fmt will have more precise control
> over formatting, and we can maybe add special formatting directives for
> reflect.Deep.
>
> What do you think?
Well, we already have fmt.Printf("%#v", value).
I don't see any obvious reason to add printing to the reflect package.
It doesn't require any internal information, and can be written
entirely separately. And, there will inevitably be a lot of desire
for customization of the printed output, which will lead to a complex
API.
Basically: https://golang.org/doc/faq#x_in_std .
Ian
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcW48Y%3DXz51daYM4qkrrDdj2wuCm6dBOa%3DR9vgBMVZatig%40mail.gmail.com.