feat(查询优化): 剔除返回结果首尾空白字符

This commit is contained in:
xiaoqidun 2021-04-09 12:45:47 +08:00
parent 5303137428
commit 35d03559c6

View File

@ -8,6 +8,7 @@ import (
"golang.org/x/text/transform" "golang.org/x/text/transform"
"io/ioutil" "io/ioutil"
"net" "net"
"strings"
"sync" "sync"
) )
@ -138,8 +139,8 @@ func QueryIP(queryIp string) (city string, area string, err error) {
} }
} }
} }
city = gb18030Decode([]byte(city)) city = strings.TrimSpace(gb18030Decode([]byte(city)))
area = gb18030Decode([]byte(area)) area = strings.TrimSpace(gb18030Decode([]byte(area)))
ipCache.Store(queryIp, cache{City: city, Area: area}) ipCache.Store(queryIp, cache{City: city, Area: area})
return return
} }