go-spew icon indicating copy to clipboard operation
go-spew copied to clipboard

More config states?

Open jrmiller82 opened this issue 11 years ago • 5 comments

Hi! Thanks for writing go-spew; it's helped me a lot with large structs.

What I was wondering is how hard would it be to add in another bool to ConfigState, say {SimpleDump: true} that would get rid of type and length and the extra info? Or break it down into smaller flags like a Length bool, Type bool, etc..

Sometimes I want the entire output; and sometimes I just want to see values without all of the extra info.

I love spew and I will continue to use it. I just wanted to use only spew for my pretty-printing to stdout.

Thoughts? Or any pointers on me forking it and trying to add that functionality?

jrmiller82 avatar Nov 11 '14 06:11 jrmiller82

I'd like to see this as well.

zeekay avatar Nov 30 '14 23:11 zeekay

I think an interesting idea would be to use the browser for dump output rather than stdout. Then, together with some logic in the frontend, you could dynamically show less or more information about a struct. For example, it could have collapsible fields that you can expand or collapse.

Making that happen is a lot of work, so I haven't committed to the idea fully yet, but I wanted to share it since it's relevant.

dmitshur avatar Dec 01 '14 02:12 dmitshur

Is there any reason spew.Printf won't suffice if you don't want the full behavior or spew.Dump? I'm not opposed to adding configuration options that are useful, but it seems like, in this case, you're after what spew.Printf already provides.

davecgh avatar Dec 16 '14 01:12 davecgh

@davecgh Firstly, thanks for spew. It's awesome.

Unless there's some option that I'm missing, when using spew.Printf, the output is printed sequentially without any new line after each field in the way that spew.Dump does.

I.e. spew.Printf may give me <*>(0x2082401c0){A:234234 B:<nil> C: D:<nil>}, but not:

<*>(0x2082401c0){
   A: 234234 
   B: <nil>
   C: 
   D: <nil>
}

johngb avatar Dec 29 '14 12:12 johngb

I really like this package. After some usage I believe the current format is very useful for all values which contain structs with pointers.. however anything which is a map/slice of non-structs/pointers (misc json data, yaml, etc) I think reads easier in a simpler format.. closer to JSON. I cloned and hacked(very poorly, but quickly) my local copy to get this behavior. Would be cool if some formatting options made it's way in.. the auto detection is kind of a silly but I just find both modes so useful!

cstockton avatar Nov 14 '15 17:11 cstockton