You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-fly/tools/ip.go

19 lines
306 B

package tools
import (
"github.com/ipipdotnet/ipdb-go"
)
func ParseIp(myip string) *ipdb.CityInfo {
db, err := ipdb.NewCity("./config/city.free.ipdb")
if err != nil {
return nil
}
db.Reload("./config/city.free.ipdb")
c, err := db.FindInfo(myip, "CN")
if err != nil {
return nil
}
return c
}