3 ms·
Thank you for taking your time to review my code. Yes, it is a beginner's project :D 1) How do I format the JSON for readability or should I ignore that? 2) T
by muzzammildotxyz 8y ago
Thank you for taking your time to review my code. Yes, it is a beginner's project :D
1) How do I format the JSON for readability or should I ignore that?
2) Thanks for that. Didn't know about it. Any ideas on how I can fix that? Maybe I can check if it is a file and not a directory and ask for input again for y/n?
- dewey 8y agoYou're welcome. 1) What do you mean exactly? The usual way would be to keep your data in a struct like: type configuration struct { Name string `json:"name"` } and then marshall it into a json string like: https://play.golang.org/p/uWvwBY4h03n https://play.golang.org/p/uWvwBY4h03n If you need more details feel free to contact me. Address is in my profile.
- muzzammildotxyz 8y agoNo, I meant the readability in .json file. Should I care for that anyway? Also, great website! :D
- dewey 8y agoYou don’t have to worry about that and don’t have to manually format it.
- muzzammildotxyz 8y agohttps://golang.org/pkg/encoding/json/#MarshalIndent https://golang.org/pkg/encoding/json/#MarshalIndent :D
- muzzammildotxyz 8y agoPlease take a look at this: https://github.com/muhammadmuzzammil1998/Log-mailer/commit/fdf8467c4f8e7ea39b58dbd5aad9eff718c6dedb https://github.com/muhammadmuzzammil1998/Log-mailer/commit/f...
- Vendan 8y agohttps://golang.org/pkg/encoding/json/#MarshalIndent https://golang.org/pkg/encoding/json/#MarshalIndent if you want to "pretty print" the json output
- muzzammildotxyz 8y agoThat's great! :D Thanks!