• Jean de Klerk's avatar
    reflect: give type hints in error messages · 09824ccf
    Jean de Klerk authored
    Currently, if you call various reflect methods you might get a panic with a
    message like, "reflect: Field of non-struct type". Sometimes it's easy to
    grok what's going on, but other times you need to laboriously go perform
    reflect.ValueOf(myType).Kind().
    
    This CL just adds that detail to the error message, saving debuggers the
    extra step and making the error message more clear.
    
    Change-Id: I7e0c211a3001e6b217b828cbcf50518080b5cb1e
    Reviewed-on: https://go-review.googlesource.com/c/go/+/183097Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
    Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    09824ccf
type.go 85.1 KB