Skip to content


Subversion checkout URL

You can clone with
Download ZIP
GeoIP API for Golang
Go Perl
Latest commit e5f8ea0 @abh Merge pull request #17 from muesli/master
Use pkg-config to retrieve LDFLAGS and CFLAGS for geoip.

GeoIP API for Go

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

Install with go get 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.


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("")

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


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

Something went wrong with that request. Please try again.