Skip to content
GO Lib GeoIP API for Maxmind
Go
Find file
Latest commit c78e8bd Mar 11, 2014 @nranchev Merge pull request #9 from borisz/master
Add missing countries
Failed to load latest commit information.
example Remove unused import Jun 27, 2012
LICENSE.txt Adding license file May 25, 2013
README.textile Removing one item from the todo list Feb 20, 2011
libgeo.go Add missing countries Mar 5, 2014

README.textile

General Description

This is the Go implementation of the Maxmind GeoIP API. It is incomplete and work in progress the initial goal is support only two of the database types – the City Lite and Country Lite. The only supported method is loading the full db on startup into memory (memory cache).

Supported Access Methods

  • In Memory (Load(string))

Supported Database Formats

  • Country Edition (dbType=1)
  • City Edition REV 0 (dbType=6)
  • City Edition REV 1 (dbType=2)

Supported Lookups

  • By IP Address (GetLocationByIP(string))
  • By IP Number (GetLocationByIPNum(uint32))

Supported Responses

  • CountryCode string (available in all databases)
  • CountryName string (available in all databases)
  • City string
  • Region string
  • PostalCode string
  • Latitude float32
  • Longitude float32

To Do

  • Implement better error handling (report the error on load and lookups)
  • Better returns, country edition has only code and name (perhaps use interfaces)
  • Add test cases and benchmarking
  • Add support for more database formats

Build

make (See Makefile for more details)

Example

./example DBFILE IPADDRESS (i.e. ./example GeoIP.dat 1.1.1.1)

Usage

Please see example.go for a complete example of how to use this library.

Something went wrong with that request. Please try again.