Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
GeoIP API for Golang
Branch: master

This branch is 56 commits behind abh:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

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.

Something went wrong with that request. Please try again.