Get Started With IP2Proxy Go Module

Dependencies

This library requires IP2Proxy BIN database to function. You may download the BIN database at


Installation

To install this module type the following:

go get github.com/ip2location/ip2proxy-go/v4

							
						

Sample Codes

Query geolocation information from BIN database

You can query the geolocation information from the IP2Proxy BIN database as below:

package main

import (
	"fmt"
	"strconv"
	"github.com/ip2location/ip2proxy-go/v4"
)

func main() {
	db, err := ip2proxy.OpenDB("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE.BIN")
	
	if err != nil {
		return
	}
	ip := "199.83.103.79"
	all, err := db.GetAll(ip)
	
	if err != nil {
		fmt.Print(err)
		return
	}
	
	fmt.Printf("ModuleVersion: %s\n", ip2proxy.ModuleVersion())
	fmt.Printf("PackageVersion: %s\n", db.PackageVersion())
	fmt.Printf("DatabaseVersion: %s\n", db.DatabaseVersion())
	
	fmt.Printf("IsProxy: %s\n", strconv.Itoa(int(all.IsProxy)));
	fmt.Printf("ProxyType: %s\n", all.ProxyType);
	fmt.Printf("CountryShort: %s\n", all.CountryShort);
	fmt.Printf("CountryLong: %s\n", all.CountryLong);
	fmt.Printf("Region: %s\n", all.Region);
	fmt.Printf("City: %s\n", all.City);
	fmt.Printf("Isp: %s\n", all.Isp);
	fmt.Printf("Domain: %s\n", all.Domain);
	fmt.Printf("UsageType: %s\n", all.UsageType);
	fmt.Printf("Asn: %s\n", all.Asn);
	fmt.Printf("As: %s\n", all.As);
	fmt.Printf("LastSeen: %s\n", all.LastSeen);
	fmt.Printf("Threat: %s\n", all.Threat)
	fmt.Printf("Provider: %s\n", all.Provider)
	fmt.Printf("FraudScore: %s\n", all.FraudScore)
	
	db.Close()
}

							
						

IP2Proxy Sample Database (BIN)

Sample Packages - BIN File IPv4 + IPv6
IP2Proxy PX1 Download (391.66 kB)
IP2Proxy PX2 Download (406.53 kB)
IP2Proxy PX3 Download (435.82 kB)
IP2Proxy PX4 Download (471.49 kB)
IP2Proxy PX5 Download (491.37 kB)
IP2Proxy PX6 Download (493.92 kB)
IP2Proxy PX7 Download (534.57 kB)
IP2Proxy PX8 Download (540.70 kB)
IP2Proxy PX9 Download (541.56 kB)
IP2Proxy PX10 Download (677.91 kB)
IP2Proxy PX11 Download (684.40 kB)
IP2Proxy PX12 Download (687.12 kB)

Articles & Tutorials