GeoIP API for Golang
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 58 commits behind abh:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ex
.gitignore
.travis.yml
LICENSE
README.md
geoip.go
geoip_test.go

README.md

GeoIP API for Go

This package wraps the libgeoip C library for access from Go (golang). Build Status

Install with go get https://github.com/abh/geoip and use godoc geoip to read the documentation.

There's a small example in the ex/ subdirectory.

You can download the free GeoLite Country database or you can subscribe to updates.

Examples

file := "/usr/share/GeoIP/GeoIP.dat"

gi := geoip.Open(file)
if gi == nil {
	fmt.Printf("Could not open GeoIP database\n")
}

if gi != nil {
	country := gi.GetCountry("207.171.7.51")
}

// Setup gi6 by opening the optional IPv6 database and then:
country := gi6.GetCountry_v6("2607:f238:2::5")
fmt.Println(country)

Contact

Ask Bjørn Hansen ask@develooper.com. The package MIT licensed, see the LICENSE file. Originally based on an example from blasux@blasux.ru.