Skip to content

Commit 3c236cc

Browse files
committed
settings default value
1 parent 7ea27fe commit 3c236cc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/settings/settings.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010
var data = map[string]any{}
1111
var ConfigPath = "./config.yml"
1212

13-
func Get(key string) generic.Value {
13+
func Get(key string, defaultValue ...any) generic.Value {
1414
key = strings.ToUpper(key)
1515
if v, ok := data[key]; ok {
1616
return generic.Parse(v)
1717
}
18-
18+
if len(defaultValue) > 0 {
19+
return generic.Parse(defaultValue[0])
20+
}
1921
return generic.Parse("")
2022
}
2123

0 commit comments

Comments
 (0)