mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 03:15:19 +08:00
* feat(fs): support manually trigger objs update hook * fix: support driver internal copy & move case * fix * fix: apply suggestions of Copilot
39 lines
678 B
Go
39 lines
678 B
Go
package setting
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
|
)
|
|
|
|
func GetStr(key string, defaultValue ...string) string {
|
|
val, _ := op.GetSettingItemByKey(key)
|
|
if val == nil {
|
|
if len(defaultValue) > 0 {
|
|
return defaultValue[0]
|
|
}
|
|
return ""
|
|
}
|
|
return val.Value
|
|
}
|
|
|
|
func GetInt(key string, defaultVal int) int {
|
|
i, err := strconv.Atoi(GetStr(key))
|
|
if err != nil {
|
|
return defaultVal
|
|
}
|
|
return i
|
|
}
|
|
|
|
func GetBool(key string) bool {
|
|
return GetStr(key) == "true" || GetStr(key) == "1"
|
|
}
|
|
|
|
func GetFloat(key string, defaultVal float64) float64 {
|
|
f, err := strconv.ParseFloat(GetStr(key), 64)
|
|
if err != nil {
|
|
return defaultVal
|
|
}
|
|
return f
|
|
}
|