ip2country

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: CC-BY-SA-4.0 Imports: 3 Imported by: 1

README

ip2country

GoDoc GitHub release (latest SemVer) GitHub Go Report Card

Package ip2country uses https://github.com/oschwald/maxminddb-golang with an embedded GeoLite2 DB to map net.IPs to country ISO codes without dealing with DB files.

Example

country, _ := ip2country.Country(net.IPv4(8, 8, 8, 8))
fmt.Println(country)
// Output: US

This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com

Documentation

Overview

Package ip2country uses github.com/oschwald/maxminddb-golang with an embedded GeoLite2 db to map net.IPs to country ISO codes

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Country

func Country(ip net.IP) (string, error)

Country returns ISO code of the country that given IP belongs to.

Example
package main

import (
	"fmt"
	"github.com/cevatbarisyilmaz/ip2country"
	"net"
)

func main() {
	country, _ := ip2country.Country(net.IPv4(8, 8, 8, 8))
	fmt.Println(country)
}
Output:

US

Types

This section is empty.

Jump to

Keyboard shortcuts

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