reflection/go1.6 panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

1,164 views
Skip to first unread message

Forud A

unread,
Jan 22, 2016, 6:21:25 AM1/22/16
to golang-nuts
I have this code http://play.golang.org/p/pChq1RbIz5 and there is no problem in go <1.6 (sure about go 1.2 to go 1.5, see this travis build https://travis-ci.org/fzerorubigd/onion/builds/104060727 ) but in go 1.6 I get 

panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

Not sure if this is really a bug or if this is intended to be this way. Should I file a bug?

Thank you!

Ian Lance Taylor

unread,
Jan 22, 2016, 10:18:37 AM1/22/16
to Forud A, golang-nuts

Forud A

unread,
Jan 22, 2016, 11:16:07 AM1/22/16
to golang-nuts, fz...@rubi.gd
So there is no way to access the exported field in an unexported embedded structure via reflection? since the Go syntax allow that. 

roger peppe

unread,
Jan 22, 2016, 12:28:42 PM1/22/16
to Forud A, golang-nuts
For your example I'd do this: http://play.golang.org/p/Qi_BUiz2sr
> --
> 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 golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Forud A

unread,
Jan 22, 2016, 4:04:03 PM1/22/16
to golang-nuts, fz...@rubi.gd
Thank you for you fix. 
Reply all
Reply to author
Forward
0 new messages