DEV Community

Cover image for How to pretty print json with golang ?

How to pretty print json with golang ?

softdev434 on August 13, 2023

As you know by default in Go you will use fmt to print json data, this is ok but the data will be not beuatiful in the terminal, take this util fun...
Collapse
 
schemetastic profile image
Rodrigo Isaias Calix

Hello!

Your post seems very useful. To improve it a little, do you think you could share a sample of how JSON data does look with fmt and compare it with the util function you shared?

And by the way, welcome to the DEV Community. I hope I can see more Go posts from you in the future! You know what? I'll follow you. 😉

Collapse
 
softdev434 profile image
softdev434

Thank you for your advice.

Collapse
 
stephencherry profile image
Stephen Olujare

Hello SoftDev434,
I must confess your headline seems interest but when i check the post it seems straight forward too but i am curious why you did not share a smaple out here. That way i will have consider if its pretty or not! Meanwhile, I think Logrus print output to console in a pretty way too. You might want to look into that as well.

Thank you for sharing though. I will follow you.