[go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread John
I know we have plenty of pretty printing out there, but i'm looking for a package that can print the Go representation of a Struct out to screen. So given: var x := &myStruct{ A: "hello" } someLib.Print(x) I get: &myStruct{ A: "hello" } I'm sure someone has used reflection to do this and

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread 'Axel Wagner' via golang-nuts
Does fmt.Printf("%#v", v) do what you want? On Mon, Aug 15, 2022 at 4:27 PM John wrote: > I know we have plenty of pretty printing out there, but i'm looking for a > package that can print the Go representation of a Struct out to screen. > > So given: > > var x := &myStruct{ > A: "hello" > } >

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread John
Hey axel, Thanks for the reply, but unfortunately not. Because that is going to simply print pointer values out. I want it to unwind all of that (and handle the difficulty of recursive references). I want to be able to take what is printed and simply paste it into a file assigned to a variabl

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread John
Hey axel, I recognize the problem space you are discussing. There are a couple strategies I could implement to try and solve the problems. And I'm not 100% sure you can solve all of them. But I certainly don't want to jump down the rabbit hole of reflection myself if I don't have to. So I'm

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread Ian Davis
Perhaps https://github.com/kortschak/utter might suit your needs? On Mon, 15 Aug 2022, at 4:07 PM, John wrote: > Hey axel, > > I recognize the problem space you are discussing. There are a couple > strategies I could implement to try and solve the problems. And I'm not 100% > sure you can solv

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-08-15 at 07:26 -0700, John wrote: > I know we have plenty of pretty printing out there, but i'm looking > for a package that can print the Go representation of a Struct out to > screen. > > So given: > > var x := &myStruct{ >   A: "hello" > } > > someLib.Print(x) > > I get: > > &myStru

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread John
Thank you everyone who responded. Gave utter a look and its pretty decent. I found litter a bit more developed around the circular reference area. But both were great suggestions and just what I was looking for. Again, thank you for helping me find these! On Monday, August 15, 2022 at 3:59:0

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-16 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-08-15 at 21:23 -0700, John wrote: > Thank you everyone who responded.  Gave utter a look and its pretty > decent.  I found litter a bit more developed around the circular > reference area.  But both were great suggestions and just what I was > looking for. I would be careful with lit