sypexgeo

package module
Version: v1.0.0-...-831ec79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2018 License: MIT Imports: 6 Imported by: 0

README

go-sypexgeo

SypexGeo API bindings for Go (provides access data from SypexGeo IP database files). Accepts only SypexGeo 2.2 or above format.

For more information about Sypex Geo databases and their features please visit http://sypexgeo.net.

Direct DB links that might became broken over time:

Documentation

Docs on godoc.org

How To Install

go get gopkg.in/night-codes/go-sypexgeo.v1

Getting Started

package main

import "gopkg.in/night-codes/go-sypexgeo.v1"

func main() {
    geo := sypexgeo.New("/path/to/db/SxGeoCity.dat")
    info, err := geo.GetCityFull("93.73.35.74")
}

License

MIT License

Copyright (C) 2015 Oleksiy Chechel (alex.mirrr@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package sypexgeo to access data from Sypex Geo IP database files, accepts only SypexGeo 2.2 databases

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	ID     uint32
	NameEn string
	NameRu string
	Lon    float32
	Lat    float32
}

City struct

type Country

type Country struct {
	ID     uint8
	ISO    string
	NameEn string
	NameRu string
	Lon    float32
	Lat    float32
}

Country struct

type Region

type Region struct {
	ID     uint32
	ISO    string
	NameEn string
	NameRu string
}

Region struct

type Result

type Result struct {
	Country Country
	Region  Region
	City    City
}

Result of geoip lookup

type SxGEO

type SxGEO struct {
	Version float32
	Updated uint32
	// contains filtered or unexported fields
}

SxGEO main object

func New

func New(filename string) SxGEO

New SxGEO object

func (*SxGEO) City

func (s *SxGEO) City(IP string) (City, error)

City info by IP

func (*SxGEO) Country

func (s *SxGEO) Country(IP string) (Country, error)

Country info by IP

func (*SxGEO) GetCity

func (s *SxGEO) GetCity(IP string) (map[string]interface{}, error)

GetCity get short info by IP

func (*SxGEO) GetCityFull

func (s *SxGEO) GetCityFull(IP string) (map[string]interface{}, error)

GetCityFull get full info by IP (with regions and countries data)

func (*SxGEO) GetCountry

func (s *SxGEO) GetCountry(IP string) (string, error)

GetCountry return string country iso-code, like `RU`, `UA` etc.

func (*SxGEO) GetCountryID

func (s *SxGEO) GetCountryID(IP string) (int, error)

GetCountryID return integer country identifier

func (*SxGEO) Info

func (s *SxGEO) Info(IP string) (Result, error)

Info by IP

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL