优化查询IP地址

This commit is contained in:
2024-10-17 13:53:38 +08:00
parent 32adcf148e
commit 866043b976
8 changed files with 47 additions and 35 deletions

Binary file not shown.

View File

@@ -46,6 +46,10 @@ func main() {
log.Fatalf("解析 JSON 时出错: %v", err)
}
// 提取并打印 continent 和 country 字段
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
if ipInfo.Msg == "查询成功" {
// 提取并打印 continent 和 country 字段
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
} else {
fmt.Printf("查询失败\n")
}
}