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

Allow disabling address of functions #124

Open flimzy opened 4 years ago

flimzy commented 4 years ago

Structs with function types output the function address, even with DisablePointerAddresses: true. Perhaps that makes sense, since a function type isn't really a pointer. But it would be great to be able to disable these addresses. To reproduce:

package main

import (
    "github.com/davecgh/go-spew/spew"
)

func main() {
    cf := spew.ConfigState{
        DisablePointerAddresses: true,
    }
    x := struct {
        fn func()
    }{
        fn: func() {},
    }
    cf.Dump(x)
}

Which produces the following output:

(struct { fn func() }) {
fn: (func()) 0x4c0020
}

playground