In Go, I can print a type of a structure by fmt.Printf("%T",Struct{})
however this creates a new structure and hence taking up a memory. So I may just print fmt.Printf("main.Struct")
, but then suppose somebody refactors the name of the Struct
, then the print statement does not get updated and the code breaks.
How could I print a type of a structure without creating its instance?