• Stars
    star
    1,180
  • Rank 39,639 (Top 0.8 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GoLang port of Google's libphonenumber library

phonenumbers

Build Status codecov GoDoc

golang port of Google's libphonenumber, forked from libphonenumber from ttacon which in turn is a port of the original Java library.

You can see a live demo of the number parsing of the master branch of this library at https://phonenumbers.temba.io/ Compare results with the official Google Java version.

This fork fixes quite a few bugs and more closely follows the official Java implementation. It also adds the buildmetadata cmd to allow for rebuilding the metadata protocol buffers, country code to region maps and timezone prefix maps. We keep this library up to date with the upstream Google repo as metadata changes take place, usually no more than a few days behind official Google releases.

This library is used daily in production for parsing and validation of numbers across the world, so is well maintained. Please open an issue if you encounter any problems, we'll do our best to address them.

Version Numbers

As we don't want to bump our major semantic version number in step with the upstream library, we use independent version numbers than the Google libphonenumber repo. The release notes will mention what version of the metadata a release was built against.

Usage

// parse our phone number
num, err := phonenumbers.Parse("6502530000", "US")

// format it using national format
formattedNum := phonenumbers.Format(num, phonenumbers.NATIONAL)

Rebuilding Metadata and Maps

The buildmetadata command will fetch the latest XML file from the official Google repo and rebuild the go source files containing all the territory metadata, timezone and region maps.

It will rebuild the following files:

  • gen/metadata_bin.go - protocol buffer definitions for all the various formats across countries etc..
  • gen/shortnumber_metadata_bin.go - protocol buffer definitions for ShortNumberMetadata.xml
  • gen/countrycode_to_region_bin.go - information needed to map a contry code to a region
  • gen/prefix_to_carrier_bin.go - information needed to map a phone number prefix to a carrier
  • gen/prefix_to_geocoding_bin.go - information needed to map a phone number prefix to a city or region
  • gen/prefix_to_timezone_bin.go - information needed to map a phone number prefix to a city or region
% go install github.com/nyaruka/phonenumbers/cmd/buildmetadata
% $GOPATH/bin/buildmetadata

More Repositories

1

smartmin

Django Smartmin - An admin-like utility for users
Python
207
star
2

courier

Messaging gateway for RapidPro/TextIt.
Go
114
star
3

android-sms-relay

Simple Android application that provides reliable relaying of SMS messages to and from a server through HTTP.
Java
87
star
4

floweditor

Graphical flow editor for the TextIt platform.
JavaScript
70
star
5

goflow

Flow engine for RapidPro/TextIt.
Go
43
star
6

rapidsms-httprouter

Implements a router in the HTTP thread, one message per call.
Python
40
star
7

klab

The official repository for the klab.rw website which can be found at http://klab.rw/
Python
12
star
8

django-quickblocks

Easy, fast, and useful content snippets for your Django site.
JavaScript
9
star
9

ezconf

Easy configuration by convention from TOML, environment variables and command line arguments
Go
8
star
10

gocommon

Common utility library for the TextIt platform.
Go
7
star
11

nsms

Provides a base package and install for building RapidSMS apps.
Python
6
star
12

jangod

Fork of jangod project on Google Code
Java
6
star
13

pysmsrouter

Very simple framework for handling disparate SMS backends and routing them to an HTTP endpoint. So far this is only useful for RapidSMS
Python
5
star
14

jukebox

Django project to manage the kLab jukebox.
JavaScript
5
star
15

rp-indexer

Content indexing service for RapidPro/TextIt.
Go
5
star
16

temba-components

General web components for site building
TypeScript
4
star
17

rapidsms-polls

The 'P' in CPBL, a rapid app
JavaScript
4
star
18

nyaruka-sms

Android based SMS platform.
Java
3
star
19

null

golang library for nullable types
Go
3
star
20

redisx

library of Go utilities for Redis
Go
3
star
21

xlsxlite

Lightweight XLSX writer with emphasis on minimizing memory usage.
Python
3
star
22

libphonenumber

Fork of http://code.google.com/p/libphonenumber/
C++
3
star
23

elasticsearch-action

GitHub Action to setup an Elasticsearch instance
Shell
3
star
24

gojunebug

Go
2
star
25

posm-extracts

Current version of OSM extracts based on POSM tool
2
star
26

rp-archiver

Content archival service for RapidPro/TextIt.
Go
2
star
27

rp-clover

Router for incoming messages to RapidPro, takes care of changing contact affinity based on keywords and routing incoming messages based on that affinity.
Go
2
star
28

nsms-plus

Includes additional super secret magic sauce Nyaruka uses to make kick ass products.
JavaScript
1
star
29

posm

Extract tools for OSM data
Python
1
star
30

kannel

Kannel
C
1
star
31

canary

Simple golang tool to check health of openswan tunnel and restart if down
Go
1
star
32

sigtrac

measuring stuff
Python
1
star
33

django-mosquare

Mobile Monday Site for Kigali
Python
1
star
34

sawanet-django-who

A sample Django application that will work using AppFog.com and Sawanet.com.
Python
1
star
35

librato

Basic Librato client library with batching of events
Go
1
star
36

go-locales

Library to make GNU C Library Locales accessible in go.
Go
1
star