-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
42 lines (32 loc) · 909 Bytes
/
config.go
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
34
35
36
37
38
39
40
41
42
package larago
import (
"fmt"
dotaccess "github.com/maxwellhealth/go-dotaccess"
)
// ConfigRepository used to store and get access to application config vars.
type ConfigRepository struct {
config Config
}
// Env returns current environment name.
func (c *ConfigRepository) Env() string {
return c.config.Env()
}
// Debug returs debug mode state.
func (c *ConfigRepository) Debug() bool {
return c.config.Debug()
}
// Get value from config using dot-notation.
func (c *ConfigRepository) Get(key string) interface{} {
value, err := dotaccess.Get(c.config, key)
if err != nil {
panic(fmt.Sprintf("Can not resolve config value: %s", key))
}
return value
}
// Set value to config using dot-notation.
func (c *ConfigRepository) Set(key string, value interface{}) {
err := dotaccess.Set(c.config, key, value)
if err != nil {
panic(fmt.Sprintf("Can not resolve config value: %s", key))
}
}