github.com/admpub/ip2country

Simple IP to Country ISO Code Mapper


License
CC-BY-SA-4.0
Install
go get github.com/admpub/ip2country

Documentation

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