func (gi *GeoIP) GetName(ip string) (name string, netmask int) {
	if gi.db == nil {
		return
	}
	gi.mu.Lock()
	defer gi.mu.Unlock()
	cip := C.CString(ip)
	defer C.free(unsafe.Pointer(cip))
	cname := C.GeoIP_name_by_addr(gi.db, cip)
	if cname != nil {
		name = C.GoString(cname)
		defer C.free(unsafe.Pointer(cname))
		netmask = int(C.GeoIP_last_netmask(gi.db))
		return
	}
	return
}
Works on the ASN, Netspeed, Organization and probably other
databases, takes and IP string and returns a "name" and the
netmask.
package geoip
import "C"
import (
	"fmt"
	"log"
	"os"
	"runtime"
	"sync"
	"unsafe"
)
type GeoIP struct {
	db *C.GeoIP
	mu sync.Mutex
}
func (gi *GeoIP) free() {
	if gi == nil {
		return
	}
	if gi.db == nil {
		gi = nil
		return
	}
	C.GeoIP_delete(gi.db)
	gi = nil
	return
}
func Open(files ...string) (*GeoIP, error) {
	return OpenDb(files, GEOIP_MEMORY_CACHE)
}
func OpenDb(files []string, flag int) (*GeoIP, error) {
	if len(files) == 0 {
		files = []string{
			"/usr/share/GeoIP/GeoIP.dat",        
			"/usr/share/local/GeoIP/GeoIP.dat",  
			"/usr/local/share/GeoIP/GeoIP.dat",  
			"/opt/local/share/GeoIP/GeoIP.dat",  
			"/usr/share/GeoIP/GeoIP.dat",        
		}
	}
	g := &GeoIP{}
	runtime.SetFinalizer(g, (*GeoIP).free)
	var err error
	for _, file := range files {
		if _, err := os.Stat(file); err != nil {
			if os.IsExist(err) {
				log.Println(err)
			}
			continue
		}
		cbase := C.CString(file)
		defer C.free(unsafe.Pointer(cbase))
		g.db, err = C.GeoIP_open(cbase, C.int(flag))
		if g.db != nil && err != nil {
			break
		}
	}
	if err != nil {
		return nil, fmt.Errorf("Error opening GeoIP database (%s): %s", files, err)
	}
	if g.db == nil {
		return nil, fmt.Errorf("Didn't open GeoIP database (%s)", files)
	}
	C.GeoIP_set_charset(g.db, C.GEOIP_CHARSET_UTF8)
	return g, nil
}
func SetCustomDirectory(dir string) {
	cdir := C.CString(dir)
	C.GeoIP_setup_custom_directory(cdir)
}
func OpenTypeFlag(dbType int, flag int) (*GeoIP, error) {
	g := &GeoIP{}
	runtime.SetFinalizer(g, (*GeoIP).free)
	var err error
	g.db, err = C.GeoIP_open_type(C.int(dbType), C.int(flag))
	if err != nil {
		return nil, fmt.Errorf("Error opening GeoIP database (%d): %s", dbType, err)
	}
	if g.db == nil {
		return nil, fmt.Errorf("Didn't open GeoIP database (%d)", dbType)
	}
	C.GeoIP_set_charset(g.db, C.GEOIP_CHARSET_UTF8)
	return g, nil
}
func OpenType(dbType int) (*GeoIP, error) {
	return OpenTypeFlag(dbType, GEOIP_MEMORY_CACHE)
}
func (gi *GeoIP) GetOrg(ip string) string {
	name, _ := gi.GetName(ip)
	return name
}