I agree json.MarshalIndent is great. However, be aware that 
json.MarshalIndent will not output private (lowercase) fields of the struct.

On Monday, November 18, 2019 at 3:29:28 AM UTC-6, anderso...@blacklane.com 
wrote:
>
> Hi Sankar,
>
> Not really, a easy trick is to use json.MarshalIndent. It helped me a lot 
> :)
>
> playgound: https://play.golang.org/p/nfr2ANR6pPH
>
> type A struct {
>     A int
>     B string
>     C map[int]string
> }
>
> func main() {
>     aa := A{
>         A: 1,
>         B: "2",
>         C: map[int]string{3: "3"},
>     }
>
>     bs, _ := json.MarshalIndent(aa, "", "    ")
>     fmt.Printf("%#v\n", aa)
>     fmt.Println(string(bs))
>
> }
>
>
>
> On Friday, 15 November 2019 06:17:29 UTC+1, Sankar wrote:
>>
>> Hi
>>
>> In Javascript world I have this handy tool Prettier which will 
>> automatically, reproducibly break long lines of code into multiple lines 
>> (and also merge parameters into a single line if some elements are 
>> removed). 
>>
>> Are there similar tools available for Golang ? Either as a standalone 
>> program or as VSCode/Goland plugins.
>>
>> From https://github.com/golang/go/issues/11915 I believe that go team 
>> may not address it as natively as gofmt/goimports. But are there any other 
>> hacks/tools that people already use to break long lines ? 
>>
>> Thanks.
>>
>> Sankar
>>
>

-- 
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/b2a80d30-5088-4436-9380-00b45f25cce2%40googlegroups.com.

Reply via email to