C Library
PHP Module
Perl Module
Ruby Library
Python Library
Apache Module
Nginx Module
Node.js Module
Cocoa / Objective C Library
Pascal Library
D Library
Go Package
Erlang Module
Haskell Package
Debian Package
Lua Package
Kotlin Module
Scala Library
OpenResty Package
Splunk Add-on
Apache Kafka Transform
OCaml Module
Deno Module
R Package
.NET Component
Java Component
HTTP Module
ActiveX / COM DLL
IP2Location IP Geolocation Go Package
This IP Geolocation package is the Go programming language package to support all IP2Location™ database products. It has been optimized for speed and memory utilization. Developers can use the module to query all IP2Location™ binary databases for applications written using the Go programming language.
go get github.com/ip2location/ip2location-go/v9
package main
import (
"fmt"
"github.com/ip2location/ip2location-go/v9"
)
func main() {
db, err := ip2location.OpenDB("./IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.BIN")
if err != nil {
fmt.Print(err)
return
}
ip := "8.8.8.8"
results, err := db.Get_all(ip)
if err != nil {
fmt.Print(err)
return
}
fmt.Printf("country_short: %s\n", results.Country_short)
fmt.Printf("country_long: %s\n", results.Country_long)
fmt.Printf("region: %s\n", results.Region)
fmt.Printf("city: %s\n", results.City)
fmt.Printf("isp: %s\n", results.Isp)
fmt.Printf("latitude: %f\n", results.Latitude)
fmt.Printf("longitude: %f\n", results.Longitude)
fmt.Printf("domain: %s\n", results.Domain)
fmt.Printf("zipcode: %s\n", results.Zipcode)
fmt.Printf("timezone: %s\n", results.Timezone)
fmt.Printf("netspeed: %s\n", results.Netspeed)
fmt.Printf("iddcode: %s\n", results.Iddcode)
fmt.Printf("areacode: %s\n", results.Areacode)
fmt.Printf("weatherstationcode: %s\n", results.Weatherstationcode)
fmt.Printf("weatherstationname: %s\n", results.Weatherstationname)
fmt.Printf("mcc: %s\n", results.Mcc)
fmt.Printf("mnc: %s\n", results.Mnc)
fmt.Printf("mobilebrand: %s\n", results.Mobilebrand)
fmt.Printf("elevation: %f\n", results.Elevation)
fmt.Printf("usagetype: %s\n", results.Usagetype)
fmt.Printf("addresstype: %s\n", results.Addresstype)
fmt.Printf("category: %s\n", results.Category)
fmt.Printf("district: %s\n", results.District)
fmt.Printf("asn: %s\n", results.Asn)
fmt.Printf("as: %s\n", results.As)
fmt.Printf("api version: %s\n", ip2location.Api_version())
db.Close()
}
Discover Your User Locations
Retrieve geolocation data for FREE now!