qinglong-go/service/config/config.go

27 lines
459 B
Go
Raw Normal View History

2022-11-20 14:11:47 +00:00
package config
import (
"os"
"path"
"regexp"
)
var VERSION = "v1.0.0"
2023-01-12 03:21:57 +00:00
func GetKey(key, defaultValue string) string {
2022-11-20 14:11:47 +00:00
file, err := os.ReadFile(path.Join("data", "config", "config.sh"))
if err != nil {
return defaultValue
2022-11-20 14:11:47 +00:00
}
compile := regexp.MustCompile(key + `="(.*?)"`)
if !compile.Match(file) {
return defaultValue
2022-11-20 14:11:47 +00:00
}
datas := compile.FindAllStringSubmatch(string(file), 1)
return datas[0][1]
}
2023-01-12 03:21:57 +00:00
func GetVersion() string {
return VERSION
}