From 9b8215c4cceee5dea9ba9e3a8fcb26779b84e42e Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 19 一月 2022 15:31:52 +0800 Subject: [PATCH] add readme --- iploc.go | 8 ++++---- README.md | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c5480d --- /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, _ = 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"` } -- Gitblit v1.8.0