Skip to content
GeoIP API for Golang
Branch: master
Clone or download
abh Merge pull request #25 from ecosia/master
Implement `go vet` fix.
Latest commit 07cea44 May 11, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
db Download helper doesn't need perl 5.14 Oct 1, 2013
ex Implement `go vet` fix. May 10, 2016
test-db Use fixed test databases. Test on 1.3, 1.4, and tip Feb 5, 2015
.gitignore Use fixed test databases. Test on 1.3, 1.4, and tip Feb 5, 2015
.travis.yml Use fixed test databases. Test on 1.3, 1.4, and tip Feb 5, 2015
LICENSE Add very basic test Jan 30, 2013
README.md Fix 'go get' command in README Aug 27, 2013
const.go Add GeoIPOptions const section and GeoIPOptions flag param to Open(). Oct 23, 2013
geoip.go
geoip_test.go Preserve OpenType() API until we bump the package version Feb 19, 2015

README.md

GeoIP API for Go

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

Install with go get 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, err := geoip.Open(file)
if err != nil {
	fmt.Printf("Could not open GeoIP database\n")
}

if gi != nil {
	country, netmask := 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

Copyright 2012-2013 Ask Bjørn Hansen ask@develooper.com. The package is MIT licensed, see the LICENSE file. Originally based on example code from blasux@blasux.ru.

You can’t perform that action at this time.