Closed septs closed 6 years ago
func makeIPInfo(data string, languageOffset int, fields []string) *IPInfo { info := new(IPInfo) mapping := map[string]*string{ "country_name": &info.CountryName, "region_name": &info.RegionName, "city_name": &info.CityName, "owner_domain": &info.OwnerDomain, "isp_domain": &info.IspDomain, "latitude": &info.Latitude, "longitude": &info.Longitude, "timezone": &info.Timezone, "utc_offset": &info.UtcOffset, "china_admin_code": &info.ChinaAdminCode, "idd_code": &info.IddCode, "country_code": &info.CountryCode, "continent_code": &info.ContinentCode, "idc": &info.IDC, "base_station": &info.BaseStation, "country_code3": &info.CountryCode3, "european_union": &info.EuropeanUnion, "currency_code": &info.CurrencyCode, "currency_name": &info.CurrencyName, "anycast": &info.Anycast, } values := strings.Split(data, "\t") values = values[languageOffset : languageOffset+len(fields)] for index, value := range values { name := fields[index] *mapping[name] = value } return info }
@septs 暂时不会这么修改,你可以看我们的Java实现