nil-go / konf

The simplest config loader for Go that reads/watches from file, env, flag and clouds (AWS, Azure, GCP).
https://pkg.go.dev/github.com/nil-go/konf
MIT License
221 stars 9 forks source link

Unable to unmarshal to map[string]interface or interface types #459

Closed BoskyWSMFN closed 1 week ago

BoskyWSMFN commented 2 weeks ago

I encountered difficulties with converting configuration values into amqp.Table (map[string]any). As far as I understand, converting values into a variable of type interface{} is not supported, although implementing this would be quite straightforward. My question is: would I break anything globally if I add support for converting the configuration into interface{}? Of course, I will add the appropriate unit test.

ktong commented 2 weeks ago

it should be straightforward with one thing in mind: unpack the key if necessary https://github.com/nil-go/konf/blob/main/internal/maps/value.go#L15

ktong commented 2 weeks ago

It should support mapping to map: https://github.com/nil-go/konf/blob/main/internal/convert/converter.go#L84. I will double check later to see if it’s a bug.

ktong commented 2 weeks ago

Found it. It needs to add case reflect.Interface: in convert:)