Re: [go-nuts] fmt.Printf Go-syntax formated representation of the value
Hello, I've written a way for you to do it without using anything third-party. You can access and review from the link. Hope this helps; Link → https://go.dev/play/p/EAURWpjaaw_o Best, 7 Mayıs 2023 Pazar tarihinde saat 16:42:54 UTC+3 itibarıyla Wojciech S. Czarnecki şunları yazdı: > Dnia 2023-04-28, o godz. 08:45:12 > "'Dan Kortschak' via golang-nuts" napisał(a): > > > But it want to know if there is elegant way to display as formatted > > > on multi-lines (a kind of indented json but with gofmt rules)? > > Take a look here https://github.com/ohir/here and spice to taste. > > Hope this helps, > [cc due to OP message age] > > -- > Wojciech S. Czarnecki > << ^oo^ >> OHIR-RIPE > -- 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/9b78d3da-36bd-4b68-b90d-9e8c2d7b571dn%40googlegroups.com.
Re: [go-nuts] fmt.Printf Go-syntax formated representation of the value
On Thu, 2023-04-27 at 23:02 -0700, Jérôme LAFORGE wrote: > Hello, > In my unit tests when expected is not the actual result, I like > display actual value with Go-syntax. For example: > if got != expected { > t.Errorf(" %#v", got) // []string{"blah','blah"} > } > > But it want to know if there is elegant way to display as formatted > on multi-lines (a kind of indented json but with gofmt rules)? > > Thanks in advance, There are a bunch of pretty printers. I use github.com/kortschak/utter which renders as Go syntax where possible. Another that attempts to do the same thing with slightly different priorities is github.com/jba/printsrc. -- 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/1ba9e0e56ab9d926ea8932ffb67a9edfece6a48b.camel%40kortschak.io.
[go-nuts] fmt.Printf Go-syntax formated representation of the value
Hello, In my unit tests when expected is not the actual result, I like display actual value with Go-syntax. For example: if got != expected { t.Errorf(" %#v", got) // []string{"blah','blah"} } But it want to know if there is elegant way to display as formatted on multi-lines (a kind of indented json but with gofmt rules)? Thanks in advance, -- 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/a20949fd-dcaf-4b7a-95d1-542ce9c3e1a3n%40googlegroups.com.