phoneiso3166

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 2 Imported by: 1

README

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 (
    "fmt"
    phoneiso3166 "github.com/Neur0toxine/go-phone-iso3166"
)

fmt.Println(phoneiso3166.E164.Lookup(4566118311)) // prints: DK
Performance

phone-iso3166 is reasonable fast

goos: darwin
goarch: amd64
pkg: github.com/Neur0toxine/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

Documentation

Overview

Code generated by gen/gen.py DO NOT EDIT. https://blog.golang.org/generate

Code generated by gen/gen.py DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var OperatorMap = MccMap{}/* 230 elements not displayed */

Functions

func NetworkName

func NetworkName(mcc, mnc uint16) string

Types

type CountryRadix

type CountryRadix struct {
	*iradix.Tree
}
var E164 *CountryRadix

func (*CountryRadix) Lookup

func (r *CountryRadix) Lookup(msisdn uint64) string

func (*CountryRadix) LookupByteString

func (r *CountryRadix) LookupByteString(msisdn []byte) string

func (*CountryRadix) LookupString

func (r *CountryRadix) LookupString(msisdn string) string

type MccMap

type MccMap map[uint16]MncMap

type MncMap

type MncMap map[uint16]Operator

type Operator

type Operator struct {
	Country string
	Name    string
}

type OperatorRadix

type OperatorRadix struct {
	*iradix.Tree
}
var E212 *OperatorRadix

func (*OperatorRadix) Lookup

func (r *OperatorRadix) Lookup(mcc, mnc uint16) string

Jump to

Keyboard shortcuts

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