Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
fmt: Printf %v, %+v, %#v do not consider Stringer or GoStringer interfaces recursively #16698
Please answer these questions before submitting your issue. Thanks!
I also checked tip.golang.org source to see if it had been changed. It hasn't.
This playground is the minimal example: https://play.golang.org/p/A9U4LteYyF
When creating an enum that is meant to be passed around in a larger struct, I wanted to create a human readable version of it. In this case, printing with any form of
The field1 is unexported and needs to be exported by naming it Field1 otherwise fmt cant use the reflect package to "extract" the concrete value of field1 from the struct and user the Stringer and GoStringer interfaces.
if you do not want to export field1 you can define String and GoString functions for the containsEnum struct since these have direct access to field1: