Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/mudphilo/phonenumbers

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mudphilo/phonenumbers

  • v0.0.0-20230720172420-c64055573858
  • Source
  • Go
  • Socket score

Version published
Created
Source

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. (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

% go install github.com/nyaruka/phonenumbers/cmd/buildmetadata
% $GOPATH/bin/buildmetadata

FAQs

Package last updated on 20 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc