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

Feature Request: Hide certain types in output #72

Open benjamw opened 6 years ago

benjamw commented 6 years ago

I'm working with the gorilla muxer (https://github.com/gorilla/mux), and am trying to debug my routes, and am getting massive outputs that prevent me from seeing the bits I'm interested in.

A sample struct is like the following:

(*http.Route)(0xc04215a240)({
 parent: (*http.Router)(0xc04200a7e0)({

  // -- a giant struct that is too big for it's own good

 }),
 handler: (*http.JSONHandler)(0xc042004118)({
  H: (func(context.Context, http.ResponseWriter, *http.Request) (interface {}, error)) 0x786ae0
 }),
 matchers: ([]http.matcher) (len=2 cap=2) {
  (*http.routeRegexp)(0xc04200a8a0)({
   template: (string) (len=9) "/register",
   matchHost: (bool) false,
   matchQuery: (bool) false,
   strictSlash: (bool) false,
   useEncodedPath: (bool) false,
   regexp: (*regexp.Regexp)(0xc04204b4a0)({

    // -- another giant struct ...

It would be great to be able to tell spew to ignore anything (or output something like <ignored> instead) that I specify, like *http.Router and *regexp.Regexp.

If that isn't possible, maybe passing in a path, like .parent, or .matchers[n].regexp would be another option.

Thanks for an awesome script!