koding / multiconfig

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

multiconfig: add partial support for flag.Value #55

Closed rjeczalik closed 7 years ago

rjeczalik commented 7 years ago

If a type implements flag.Value interface, the Set method should be called instead of failing with:

  2016/12/04 10:38:07 multiconfig: field 'Private' has unsupported type: ptr

Partial, because for the following type:

  var _ flag.Value = (*URL)(nil)

The following works:

  type Endpoint struct {
      Public *URL
  }

  m.MustLoad(&e)

And the following does not, even though the &e is addressable:

  type Endpoint struct {
      Public URL
  }

  m.MustLoad(&e)

This is not directly the problem of multiconfig package, but with structs one, that multiconfig uses. The structs package does not handle pointers, maps and slices that one would expect for this use-case.