koding / multiconfig

Load configuration from multiple sources in Go
http://godoc.org/github.com/koding/multiconfig
MIT License
454 stars 64 forks source link

The error does not return if the file name does not end on json, yaml etc. #60

Closed podtserkovskiy closed 7 years ago

podtserkovskiy commented 7 years ago

configLoader := multiconfig.NewWithPath("1111") err := configLoader.Load(c)

rjeczalik commented 7 years ago

On a second thought I'm removing the bug label.

This is somewhat API issue here - NewWithPath does not return errors so you can't simply fail here if unexpected extension is detected (moreover the ifs could be improved to test for ".toml" instead of "toml" and so on).

Way of fixing this would be adding ErrorLoader and registering it when no valid extension is found, but it would change the behaviour the function currently has. And from the looks I think the silent failure is by design. 🤔

cihangir commented 7 years ago

Hi, yes this is not a bug, where we are creating a default loader with the given filename with a best effort. If someone needs more granular work, could use MultiLoader and get the errors.

You can see more real-world usages here