func (gi *GeoIP) GetRegion(ip string) (string, string) {
	if gi.db == nil {
		return "", ""
	}

	cip := C.CString(ip)
	defer C.free(unsafe.Pointer(cip))

	gi.mu.Lock()
	region := C.GeoIP_region_by_addr(gi.db, cip)
	gi.mu.Unlock()

	if region == nil {
		return "", ""
	}

	countryCode := C.GoString(&region.country_code[0])
	regionCode := C.GoString(&region.region[0])
	defer C.free(unsafe.Pointer(region))

	return countryCode, regionCode
}
func (gi *GeoIP) GetRegion(ip string) (string, string) {
	if gi.db == nil {
		return "", ""
	}

	cip := C.CString(ip)
	defer C.free(unsafe.Pointer(cip))

	gi.mu.Lock()
	region := C.GeoIP_region_by_addr(gi.db, cip)
	gi.mu.Unlock()

	if region == nil {
		return "", ""
	}

	countryCode := C.GoString(&region.country_code[0])
	regionCode := C.GoString(&region.region[0])
	defer C.free(unsafe.Pointer(region))

	return countryCode, regionCode
}
func ( gi * GeoIP ) GetRegion ( ip string ) ( string , string ) { if gi . db == nil { return " " , " " } cip := C . CString ( ip ) defer C . free ( unsafe . Pointer ( cip ) ) gi . mu . Lock ( ) region := C . GeoIP_region_by_addr ( gi . db , cip ) gi . mu . Unlock ( ) if region == nil { return " " , " " } countryCode := C . GoString ( & region . country_code [ 0 ] ) regionCode := C . GoString ( & region . region [ 0 ] ) defer C . free ( unsafe . Pointer ( region ) ) return countryCode , regionCode }
// Returns the country code and region code for an IP address. Requires
// the GeoIP Region database.
Returns the country code and region code for an IP address . Requires the GeoIP Region database .