-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
33 lines (27 loc) · 770 Bytes
/
config.go
File metadata and controls
33 lines (27 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package configfacade
// Config is the interface to implement to make compatible library
type Config interface {
LoadFile(path string, filename string, extension string) error
LoadEnvVars(vars map[string]string) error
Get(key string) interface{}
}
// Settings is a structure containing the main information about the configuration file and environment variables
type Settings struct {
Path string
Name string
Extension string
EnvVars map[string]string
}
// Init initialises the library instance with settings
func Init(c Config, s Settings) (Config, error) {
var err error
err = c.LoadFile(s.Path, s.Name, s.Extension)
if err != nil {
return nil, err
}
err = c.LoadEnvVars(s.EnvVars)
if err != nil {
return nil, err
}
return c, nil
}