Zeus/helper/public_func.go

30 lines
473 B
Go
Raw Normal View History

2021-12-14 13:53:22 +08:00
package bgm
2021-12-14 19:45:25 +08:00
import (
"os"
"strings"
)
type QueryMap map[string]string
2021-12-14 13:53:22 +08:00
func GetEnvDefault(key, defVal string) string {
val, ex := os.LookupEnv(key)
if !ex {
os.Setenv(key, defVal)
return defVal
}
return val
}
2021-12-14 19:45:25 +08:00
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
}