Skip to content

sundowndev/go-phone-iso3166

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phone-iso3166

Go Report Card go-doc

Maps an E.164 (international) phone number to the ISO-3166-1 alpha 2 (two letter) country code, associated with that number.

Also provides mapping for E.212 (mobile network codes, mcc+mnc) to the country.

It's based on it's python namesake onlinecity/phone-iso3166 - but uses a radix as it's datastructure.

Usage

import phoneiso3166 "github.com/onlinecity/go-phone-iso3166"
println(phoneiso3166.E164.Lookup(4566118311)) // prints: DK

Performance

phone-iso3166 is reasonable fast

goos: darwin
goarch: amd64
pkg: github.com/onlinecity/go-phone-iso3166
BenchmarkE164Lookup-8           	20000000	       102 ns/op	      16 B/op	       1 allocs/op
BenchmarkE164LookupPrealloc-8   	20000000	        74.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkE164LookupBuffer-8     	20000000	       105 ns/op	      16 B/op	       1 allocs/op
BenchmarkE164LookupString-8     	20000000	        61.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkE164LookupBytes-8      	30000000	        53.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkE164LookupNoExist-8    	10000000	       151 ns/op	      16 B/op	       1 allocs/op
BenchmarkE212Lookup-8           	10000000	       163 ns/op	       3 B/op	       1 allocs/op

About

Phonenumber to ISO 3166-1 mapping

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 62.5%
  • Python 37.5%