Go plugin with MaxMind's free GeoIP2 DB
Go Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
LICENSE
README.md
build.sh
geoip2-city.go
geoip2-city.mmdb
go-maxmind-geoip.go
go-maxmind-geoip.so

README.md

For experimental usage only!

This project contains an example with Go plugin which contains free GeoLite2 MaxMind's database of ip addresses.

It can find City by IP address.

It builds single go-maxmind-geoip.so plugin file with already included database with help of go-bindata.

How to use in Go

Download .so plugin:

wget https://raw.githubusercontent.com/plutov/go-maxmind-geoip/master/go-maxmind-geoip.so

Use functions:

p, _ := plugin.Open("./go-maxmind-geoip.so")
init, _ := p.Lookup("InitDB")
init.(func() error)()
gc, _ := p.Lookup("GetCity")
city, _ := gc.(func(r *http.Request) (string, error))(r)

Requirements

  • Linux or Darwin
  • Go 1.8

Build

./build.sh

Run tests

go test ./example/...