zhangzengfei
2022-01-19 2a866b08f0efcb886e09cf4418888434dcb6e593
add readme
1个文件已添加
2个文件已修改
34 ■■■■ 已修改文件
README.md 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iploc.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iploc_test.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
New file
@@ -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)
    }
}
```
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"`
}
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 {