Skip to content

Commit

Permalink
Added support for address type and IAB category. Added exception hand…
Browse files Browse the repository at this point in the history
…ling for wrong BIN file.
  • Loading branch information
ip2location committed Jun 18, 2021
1 parent cfcb61b commit 9ce2338
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 86 deletions.
2 changes: 1 addition & 1 deletion LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 IP2Location.com
Copyright (c) 2021 IP2Location.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
IP2Location Go Package
======================

This Go package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type from IP address by using IP2Location database. This package uses a file based database available at IP2Location.com. This database simply contains IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type as values. It supports both IP address in IPv4 and IPv6.
This Go package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type from IP address by using IP2Location database. This package uses a file based database available at IP2Location.com. This database simply contains IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, usage type, address type and IAB category as values. It supports both IP address in IPv4 and IPv6.

This package can be used in many types of projects such as:

Expand Down Expand Up @@ -40,9 +40,10 @@ import (
)

func main() {
db, err := ip2location.OpenDB("./IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
db, err := ip2location.OpenDB("./IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY.BIN")

if err != nil {
fmt.Print(err)
return
}
ip := "8.8.8.8"
Expand Down Expand Up @@ -73,6 +74,8 @@ func main() {
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("api version: %s\n", ip2location.Api_version())

db.Close()
Expand All @@ -95,4 +98,4 @@ Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
Copyright
=========

Copyright (C) 2020 by IP2Location.com, [email protected]
Copyright (C) 2021 by IP2Location.com, [email protected]
Loading

0 comments on commit 9ce2338

Please sign in to comment.