iploc

package module
v1.0.20210315 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: MIT Imports: 7 Imported by: 22

README

iploc - fastest ip country library

godoc release goreport coverage

Getting Started

try on https://play.golang.org/p/T_7jfSr0cE1

package main

import (
	"fmt"
	"net"
	"github.com/phuslu/iploc"
)

func main() {
	fmt.Printf("%s", iploc.Country(net.IP{1,1,1,1}))
}

// Output: US
Command Tool
$ go get github.com/phuslu/iploc/cmd/iploc
$ iploc 2001:4860:4860::8888
US
Benchmarks
BenchmarkCountryForIPv4-8   	20.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkCountryForIPv6-8   	38.2 ns/op	       0 B/op	       0 allocs/op
Acknowledgment

This site or product includes IP2Location LITE data available from http://www.ip2location.com.

How often are the database(iploc_db.go) updated?

Following IP2Location Lite Database, usually monthly.

Documentation

Overview

Package iploc provides fastest Geolocation Country library for Go.

package main

import (
	"fmt"
	"net"
	"github.com/phuslu/iploc"
)

func main() {
	fmt.Printf("%s", iploc.Country(net.ParseIP("2001:4860:4860::8888")))
}

// Output: US

Index

Constants

View Source
const Version = "v1.0.20210315"

Variables

This section is empty.

Functions

func Country

func Country(ip net.IP) (country []byte)

Country return ISO 3166-1 alpha-2 country code of IP.

func IsReservedIPv4 added in v1.0.20200930

func IsReservedIPv4(ip net.IP) bool

IsReservedIPv4 detects a net.IP is a reserved address, return fasle if IPv6

Types

This section is empty.

Directories

Path Synopsis
cmd
iploc command

Jump to

Keyboard shortcuts

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