https://github.com/plutov/go-maxmind-geoip
Go plugin with MaxMind's free GeoIP2 DB
https://github.com/plutov/go-maxmind-geoip
Last synced: about 1 month ago
JSON representation
Go plugin with MaxMind's free GeoIP2 DB
- Host: GitHub
- URL: https://github.com/plutov/go-maxmind-geoip
- Owner: plutov
- License: mit
- Created: 2017-04-04T09:03:57.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T03:27:14.000Z (about 8 years ago)
- Last Synced: 2025-01-30T15:45:00.756Z (3 months ago)
- Language: Go
- Size: 90.5 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### For experimental usage only!
This [project](https://github.com/plutov/go-maxmind-geoip) contains an example with Go plugin which contains free GeoLite2 MaxMind's [database of ip addresses](http://dev.maxmind.com/geoip/geoip2/geolite2/).
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/...
```