Giter Club home page Giter Club logo

phonenumbers's Introduction

phonenumbers Build Status 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. (you will need svn installed on your path)

It will rebuild the following files:

metadata_bin.go - contains the protocol buffer definitions for all the various formats across countries etc..

countrycode_to_region_bin.go - contains the information needed to map a contrycode to a region

prefix_to_carrier_bin.go - contains the information needed to map a phone number prefix to a carrier

prefix_to_geocoding_bin.go - contains the information needed to map a phone number prefix to a city or region

prefix_to_timezone_bin.go - contains the information needed to map a phone number prefix to a city or region

% cd cmd/buildmetadata && go install . && cd -
% $GOPATH/bin/buildmetadata

phonenumbers's People

Contributors

bvisness avatar coreyk avatar eugene-gurevich avatar f21 avatar iwittkau avatar janh avatar nicpottier avatar shaxbee avatar vlastv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.