Similar to this question but not quite identical.
I'm doing some code-generation, making .go files from within Go. I've got a struct, and I want to generate the text representation of it so that I can insert it as a literal into the generated code.
So, if I had myVal := SomeStruct{foo : 1, bar : 2}
, I want to get the string "SomeStruct{foo : 1, bar : 2}"
.
Is this possible in Go?
type Foo string
and{field : Foo("Bar")}
, it just prints this to{field : "Bar"}
. Any workarounds for this? – Thoughtful