All Projects → oschwald → Geoip2 Golang

oschwald / Geoip2 Golang

Licence: isc
Unofficial MaxMind GeoIP2 Reader for Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Geoip2 Golang

Geo ip
Retreive the geolocation of an IP address based on the ipinfodb.com webservice
Stars: ✭ 103 (-90.41%)
Mutual labels:  geolocation, geoip
Iploc
Fastest IP To Country Library
Stars: ✭ 224 (-79.14%)
Mutual labels:  geolocation, geoip
Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (-90.69%)
Mutual labels:  geolocation, geoip
GeoLite.mmdb
MaxMind's GeoIP2 GeoLite2 Country, City, and ASN databases
Stars: ✭ 690 (-35.75%)
Mutual labels:  geolocation, geoip
nodejs-geoip2ws
Maxmind GeoIP2 Web Services for Node.js
Stars: ✭ 47 (-95.62%)
Mutual labels:  geolocation, geoip
country
IP to country
Stars: ✭ 32 (-97.02%)
Mutual labels:  geolocation, geoip
Shiny geoip
IP to location API service
Stars: ✭ 172 (-83.99%)
Mutual labels:  geolocation, geoip
tinygeoip
🐉 tiny geoip microservice
Stars: ✭ 13 (-98.79%)
Mutual labels:  geolocation, geoip
locus
MMDB reader for geolocation and ASN lookup of IP addresses
Stars: ✭ 93 (-91.34%)
Mutual labels:  geolocation, geoip
express-ip
An Express Middleware for getting IP information
Stars: ✭ 28 (-97.39%)
Mutual labels:  geolocation, geoip
Maxminddb Golang
MaxMind DB Reader for Go
Stars: ✭ 319 (-70.3%)
Mutual labels:  geolocation, geoip
Gormt
database to golang struct
Stars: ✭ 1,063 (-1.02%)
Mutual labels:  database
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-95.34%)
Mutual labels:  database
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+751.68%)
Mutual labels:  database
Couchdb Net
EF Core-like CouchDB experience for .NET!
Stars: ✭ 50 (-95.34%)
Mutual labels:  database
Fluent
Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 1,071 (-0.28%)
Mutual labels:  database
Molecule
Scala meta-DSL for the Datomic database
Stars: ✭ 51 (-95.25%)
Mutual labels:  database
Racingworld
💥 A multiplayer online 3D game about racing 💥
Stars: ✭ 50 (-95.34%)
Mutual labels:  database
Postgresclientkit
A PostgreSQL client library for Swift. Does not require libpq.
Stars: ✭ 49 (-95.44%)
Mutual labels:  database
Spring Boot Angular5
This repository has a sample code base for spring boot and angular 5 integration.
Stars: ✭ 49 (-95.44%)
Mutual labels:  database

GeoIP2 Reader for Go

PkgGoDev

This library reads MaxMind GeoLite2 and GeoIP2 databases.

This library is built using the Go maxminddb reader. All data for the database record is decoded using this library. If you only need several fields, you may get superior performance by using maxminddb's Lookup directly with a result struct that only contains the required fields. (See example_test.go in the maxminddb repository for an example of this.)

Installation

go get github.com/oschwald/geoip2-golang

Usage

See GoDoc for documentation and examples.

Example

package main

import (
	"fmt"
	"github.com/oschwald/geoip2-golang"
	"log"
	"net"
)

func main() {
	db, err := geoip2.Open("GeoIP2-City.mmdb")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()
	// If you are using strings that may be invalid, check that ip is not nil
	ip := net.ParseIP("81.2.69.142")
	record, err := db.City(ip)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Portuguese (BR) city name: %v\n", record.City.Names["pt-BR"])
	if len(record.Subdivisions) > 0 {
		fmt.Printf("English subdivision name: %v\n", record.Subdivisions[0].Names["en"])
	}
	fmt.Printf("Russian country name: %v\n", record.Country.Names["ru"])
	fmt.Printf("ISO country code: %v\n", record.Country.IsoCode)
	fmt.Printf("Time zone: %v\n", record.Location.TimeZone)
	fmt.Printf("Coordinates: %v, %v\n", record.Location.Latitude, record.Location.Longitude)
	// Output:
	// Portuguese (BR) city name: Londres
	// English subdivision name: England
	// Russian country name: Великобритания
	// ISO country code: GB
	// Time zone: Europe/London
	// Coordinates: 51.5142, -0.0931
}

Testing

Make sure you checked out test data submodule:

git submodule init
git submodule update

Execute test suite:

go test

Contributing

Contributions welcome! Please fork the repository and open a pull request with your changes.

License

This is free software, licensed under the ISC license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].