优化
This commit is contained in:
parent
a3d1d25bd1
commit
22efb95048
@ -11,7 +11,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -429,14 +428,15 @@ func GenerateShuffledAlphabet() string {
|
||||
|
||||
// 根据IP获取国家名称
|
||||
func GetCountryByIP(ip string) (string, error) {
|
||||
resp, err := http.Get("https://ipapi.co/" + ip + "/country_name/")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(resp.Body)
|
||||
return strings.TrimSpace(buf.String()), nil
|
||||
return "", nil
|
||||
// resp, err := http.Get("https://ipapi.co/" + ip + "/country_name/")
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// defer resp.Body.Close()
|
||||
// buf := new(bytes.Buffer)
|
||||
// buf.ReadFrom(resp.Body)
|
||||
// return strings.TrimSpace(buf.String()), nil
|
||||
}
|
||||
|
||||
// 根据国家名称获取ISO 3166-1国家码
|
||||
|
||||
Loading…
Reference in New Issue
Block a user