Skip to content

Commit

Permalink
settings default value
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Jan 1, 2025
1 parent 7ea27fe commit 3c236cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
var data = map[string]any{}
var ConfigPath = "./config.yml"

func Get(key string) generic.Value {
func Get(key string, defaultValue ...any) generic.Value {
key = strings.ToUpper(key)
if v, ok := data[key]; ok {
return generic.Parse(v)
}

if len(defaultValue) > 0 {
return generic.Parse(defaultValue[0])
}
return generic.Parse("")
}

Expand Down

0 comments on commit 3c236cc

Please sign in to comment.