refactor: openpitrix module
Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
27
vendor/github.com/koding/multiconfig/multiloader.go
generated
vendored
Normal file
27
vendor/github.com/koding/multiconfig/multiloader.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user