Unfortunately that is not possible; it must be map[string]interface{} for 
my code to work correctly.

I easily, hoping there are no bugs, managed to patch gopkg.in/yaml.v2 to 
work as I want, but the code of github.com/naoina/toml and encoding.json 
are more complex:
https://pastebin.com/Arvz0WJB


Thanks
Manlio Perillo

Il giorno venerdì 12 gennaio 2018 22:27:07 UTC+1, SlothNinja ha scritto:
>
> You are unmarshalling into a map[string]interface{}.  Thus, the unmarshal 
> function is basically not told what the value should be and thus unmarshals 
> the JSON object into a map[string]interface.  If you want the value to be a 
> Postgres struct, then config must specify a Postgres value.
>
> See, e.g., https://play.golang.org/p/ER_6AL-PHQr.
>
> Jeff
>
> On Friday, January 12, 2018 at 1:30:10 PM UTC-5, Manlio Perillo wrote:
>>
>> Hi.
>>
>> Consider this example:
>> https://play.golang.org/p/q7oEp40ZCIL
>>
>> Unmarshal replaces the existing map entry with key "Postgres".
>> The documentation says:
>>
>>     To unmarshal a JSON object into a map, Unmarshal first establishes a 
>> map to use.
>>      If the map is nil, Unmarshal allocates a new map.
>>      Otherwise Unmarshal reuses the existing map, keeping existing 
>> entries.
>>      Unmarshal then stores key-value pairs from the JSON object into the 
>> map.
>>      The map's key type must either be a string, an integer, or implement 
>> encoding.TextUnmarshaler.
>>
>> Does the reported behavior conform to the documentation?
>> Personally, I would have expected the program to not panic.
>>
>>
>> Thanks
>> Manlio Perillo
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to