package geoloc import ( "fmt" "math" "net" "github.com/praserx/ipconv" ) func GetIPInfo(ipaddress string) (uint, error) { ip := net.ParseIP(ipaddress) if ip == nil { return 0, fmt.Errorf("no valid IP address") } ipnum, err := ipconv.IPv4ToInt(ip) if err != nil { return 0, err } ipnumfrom := uint(math.Floor(float64(ipnum)/float64(256))) * 256 return ipnumfrom, nil }