ip2country

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

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 3 Imported by: 1

README

Intro

Package ip2country provides IPv4 and IPv6 address to country lookups in Go.

Install

go get github.com/amitybell/ip2country

Usage

package main

import (
	"github.com/amitybell/ip2country"
	"fmt"
)

func main() {
	fmt.Println(ip2country.LookupString("1.2.3.4"))
}

License

The package itself is distributed under the MIT license.

The database is compiled from the MaxMind geolite2-city CSVs distributed by https://github.com/sapics/ip-location-db/tree/main/geolite2-country and is therefore subject to the MaxMind EULA https://www.maxmind.com/en/geolite2/eula

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup

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

Lookup returns the country (code) in which ip is located, or an error if not found.

func LookupString

func LookupString(ip string) (string, error)

LookupString is a wrapper Lookup(net.ParseIP(ip))

Types

This section is empty.

Jump to

Keyboard shortcuts

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