package ip2region import ( "fmt" "github.com/lionsoul2014/ip2region/binding/golang/ip2region" ) func Ip2Region(ip string) (*ip2region.IpInfo, error) { region, err := ip2region.New("./conf/ip2region_20200113.db") 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 }