style: 优化util GetIp格式

This commit is contained in:
Mmx
2021-12-01 21:57:40 +08:00
parent 51769ed6f0
commit dbfc802e82

View File

@@ -23,11 +23,10 @@ func Search(reg string, content string) (string, error) {
func GetIp(body string) (string, error) { func GetIp(body string) (string, error) {
//判断原正则是否有匹配,如果无就使用新正则尝试 //判断原正则是否有匹配,如果无就使用新正则尝试
if ip, err := Search("id=\"user_ip\" value=\"(.*?)\"", body); err == nil { if ip, e := Search("id=\"user_ip\" value=\"(.*?)\"", body); e == nil {
return ip, nil return ip, nil
} }
ip, err := Search("ip : \"(.*?)\"", body) return Search("ip : \"(.*?)\"", body)
return ip, err
} }
func GetToken(body string) (string, error) { func GetToken(body string) (string, error) {