ipCountry

package module
v0.0.0-...-3804954 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 6 Imported by: 0

README

ip-country

An offline tool to get country by IP

Requirements

  • IP2Location™ LITE IP-COUNTRY-REGION-CITY Database

Installation

  1. Download IP2Location database for IPv4 from https://lite.ip2location.com/database/ip-country-region-city

  2. Install:

    go get https://github.com/dmitriiweb/go-ip-country
    

Usage

package main

import (
	"fmt"
	"github.com/dmitriiweb/ip_country"
)


func main() {
	path := "/home/di/Downloads/ips.csv"
	ips := []string{"5.34.169.32", "4.69.200.225"}

	res := ipCountry.GetIPData(ips, path)
	for _, row := range res {
		fmt.Printf("IP: %s\nCountry: %s\nCity: %s\n\n", row.IP, row.CountryName, row.CityName)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IP

type IP struct {
	IPFrom      uint32
	IPTo        uint32
	CountryCode string
	CountryName string
	RegionName  string
	CityName    string
}

type IPData

type IPData struct {
	IP          string
	CountryCode string
	CountryName string
	RegionName  string
	CityName    string
	Error       string
}

func GetIPData

func GetIPData(ips []string, pathToDB string) []*IPData

Jump to

Keyboard shortcuts

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