【文件属性】:
文件名称:GeoIP:用 Go 编写的 FreeGeoIP API 抽象
文件大小:3KB
文件格式:ZIP
更新时间:2021-07-12 08:12:30
Go
地理IP
GeoIP 是一个 API 抽象库,与原始包一样用 Go 编写。 该软件包利用了在其上免费提供的 RESTful API。 go.pkgdoc.org 上的。
go get github.com/polds/GeoIP
package main
import (
"fmt"
"github.com/polds/GeoIP"
)
func main() {
info, err := GeoIP.Fetch("127.0.0.1")
if err != nil {
panic(err) // Could be rate limiting or not found
}
fmt.Println(info.City)
fmt.Println(info.CountryCode)
}
该库中使用进行测试。 可以通过两种不同的方式进行测试:
go test -v
或者
【文件预览】:
GeoIP-master
----LICENSE(1KB)
----GeoIp.go(1KB)
----README.md(1KB)
----GeoIP_test.go(1KB)