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.