From 2a866b08f0efcb886e09cf4418888434dcb6e593 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 19 一月 2022 15:32:35 +0800 Subject: [PATCH] add readme --- iploc.go | 8 ++++---- iploc_test.go | 2 +- README.md | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e619e59 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +```cassandraql +package main + +import ( + "fmt" + "basic.com/valib/iploc.git" +) + +func main() { + geo, err := iploc.GetLocation() + if err == nil { + fmt.Println(geo) + } else { + fmt.Println("GetLocation:", err) + } + + geo, err = iploc.GetLocationForIp("114.114.114.114") + if err == nil { + fmt.Println(geo) + } else { + fmt.Println("GetLocationForIp:", err) + } +} +``` \ No newline at end of file diff --git a/iploc.go b/iploc.go index 44775c2..3765c71 100644 --- a/iploc.go +++ b/iploc.go @@ -9,10 +9,10 @@ // Data from ip-api.com type GeoIP struct { - InternetIp string `json:"query"` - Country string `json:"country"` - RegionName string `json:"regionName"` - City string `json:"city"` + InternetIp string `json:"query"` // 澶栫綉ip + Country string `json:"country"` // 鍥藉 + RegionName string `json:"regionName"` // 鍦板尯 + City string `json:"city"` // 鍩庡競 Lat float64 `json:"lat"` Lon float64 `json:"lon"` } diff --git a/iploc_test.go b/iploc_test.go index 74bd416..025248d 100644 --- a/iploc_test.go +++ b/iploc_test.go @@ -13,7 +13,7 @@ fmt.Println("GetLocation:", err) } - geo, _ = GetLocationForIp("114.114.114.114") + geo, err = GetLocationForIp("114.114.114.114") if err == nil { fmt.Println(geo) } else { -- Gitblit v1.8.0