feat: and 查询

This commit is contained in:
2021-12-14 19:45:25 +08:00
parent 9977fd1a16
commit 3679aaab18
7 changed files with 117 additions and 19 deletions
+18 -1
View File
@@ -1,6 +1,11 @@
package bgm
import "os"
import (
"os"
"strings"
)
type QueryMap map[string]string
func GetEnvDefault(key, defVal string) string {
val, ex := os.LookupEnv(key)
@@ -10,3 +15,15 @@ func GetEnvDefault(key, defVal string) string {
}
return val
}
func GetQueryMap(s string) QueryMap {
m := make(map[string]string)
if s != "" {
s = string([]byte(s)[1 : len([]byte(s))-1])
for _, v := range strings.Split(s, ",") {
split := strings.Split(v, "=")
m[split[0]] = split[1]
}
}
return m
}