feat: geo ip.

This commit is contained in:
tx7do
2023-10-19 15:27:32 +08:00
parent 01bdf5cc06
commit 7965576c1c
8 changed files with 73 additions and 34 deletions

View File

@@ -2,15 +2,20 @@ package qqwry
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClient(t *testing.T) {
g := NewClient()
assert.NotNil(t, g)
country, city, isp, err := g.Query("47.108.149.89")
res, err := g.Query("47.108.149.89")
assert.Nil(t, err)
fmt.Println("国家:", country, "城市:", city, "服务商:", isp)
fmt.Println("国家:", res.Country, "省:", res.Province, "城市:", res.City, "服务商:", res.ISP)
assert.Equal(t, res.Country, "中国")
assert.Equal(t, res.Province, "四川省")
assert.Equal(t, res.City, "成都市")
assert.Equal(t, res.ISP, "阿里云")
}