Files
kubesphere/vendor/github.com/koding/multiconfig/multiloader.go
hongming 1b5681c12b refactor: openpitrix module
Signed-off-by: hongming <talonwan@yunify.com>
2019-09-26 13:41:00 +08:00

28 lines
626 B
Go

package multiconfig
type multiLoader []Loader
// MultiLoader creates a loader that executes the loaders one by one in order
// and returns on the first error.
func MultiLoader(loader ...Loader) Loader {
return multiLoader(loader)
}
// Load loads the source into the config defined by struct s
func (m multiLoader) Load(s interface{}) error {
for _, loader := range m {
if err := loader.Load(s); err != nil {
return err
}
}
return nil
}
// MustLoad loads the source into the struct, it panics if gets any error
func (m multiLoader) MustLoad(s interface{}) {
if err := m.Load(s); err != nil {
panic(err)
}
}