qinglong-go/service/config/config.go

27 lines
423 B
Go
Raw Normal View History

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