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.

Reply via email to