12345678910111213141516171819202122232425 |
- package ip2region
- import (
- "fmt"
- "github.com/lionsoul2014/ip2region/binding/golang/ip2region"
- "miads/adslib"
- )
- func Ip2Region(ip string) (*ip2region.IpInfo, error) {
- region, err := ip2region.New(adslib.GetConf().Ip2RegionFile)
- if region != nil {
- defer region.Close()
- }
- if err != nil {
- fmt.Println(err)
- return nil, err
- }
- ipInfo, err := region.BtreeSearch(ip)
- if err != nil {
- return nil, err
- }
- return &ipInfo, nil
- }
|