Course you could think of something like: func (ms MyStruct) String() string { b, err := json.Marshal(ms) if err != nil { panic(err) } return string(b) }
but this is not really performant, since you're calling the JSON parser for real (however, any empty field marked as "omitempty" in its tag would effectively be omitted). The only other way to go I can think of right now is to use reflection --> tags, and then choosing what you do according to what you encounter. But again, this is quite greedy (speaking of execution time). Why don't you just use spew? Course this is greedy as well but at least you don't get to re-invent the wheel. Maybe if you state your need in a clearer way, we can help you better? :) Keep GoIng ;) -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/27219c80-d2ad-4f22-8160-b48999fcea3d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.