Post AWstMc3RivErdMQdMW by jazz@hachyderm.io
 (DIR) More posts by jazz@hachyderm.io
 (DIR) Post #AWst58ZY5Ip9H16xu4 by louis@emacs.ch
       2023-06-20T13:41:31Z
       
       0 likes, 0 repeats
       
       Dear #Go, why are you sometimes so ugly?payload := map[string]interface{}{    "data": map[string]interface{}{        "references": []map[string]interface{}{            {                "provider_name": provider,                "name": map[string]string{                    "de": name,                },            },        },    },}
       
 (DIR) Post #AWstMc3RivErdMQdMW by jazz@hachyderm.io
       2023-06-20T13:44:41Z
       
       0 likes, 0 repeats
       
       @louis because it wants to use a proper struct instead. Its my theory at least.
       
 (DIR) Post #AWsukkhpJGTRMyOHgG by galdor@emacs.ch
       2023-06-20T14:00:17Z
       
       0 likes, 0 repeats
       
       @louis Oh come on, you know you're bringing this on yourself by not modelling your data with proper types ;) Even if you have a reason not to do it, you're allowed to define a type for map[string]interface{} (I do that for log data in go-log for example).
       
 (DIR) Post #AWsxoNaZV3TSh6Q09Y by louis@emacs.ch
       2023-06-20T14:34:33Z
       
       0 likes, 0 repeats
       
       @galdor @jazz But you can also make up the pig a little, so that it no longer looks quite so ugly:type H map[string]anypayload := H{    "data": H{        "references": []H{            {                "provider_name": provider,                "name": H{                    "de": name,                },            },        },    },}Of course I try to be a bit provocative and know that the canonical way is to drown in type declarations. But sometimes you just need a little one-time ad-hoc data structure just to mashal it to proper JSON.
       
 (DIR) Post #AWtreb7XveHfCRkpua by veer66@mstdn.io
       2023-06-21T01:00:14Z
       
       0 likes, 0 repeats
       
       @galdor @louis I wonder how go-fed/activity avoid a loose type, so I check the codebase. They have their codegen. 🙀