Skip to content

golang port of Google's libphonenumber

License

Notifications You must be signed in to change notification settings

heetch/libphonenumber

This branch is 14 commits ahead of, 8 commits behind ttacon/libphonenumber:master.

Folders and files

NameName
Last commit message
Last commit date
Feb 21, 2022
Jan 8, 2019
Jan 16, 2020
Dec 27, 2014
Jul 12, 2018
Jul 15, 2018
Apr 4, 2017
Jun 4, 2018
Feb 19, 2021
Feb 19, 2021
Sep 11, 2024
Sep 11, 2024
Jul 12, 2018
Apr 23, 2015
Oct 24, 2024
Oct 24, 2024

Repository files navigation

libphonenumber

golang port of Google's libphonenumber

forthebadge

Build Status GoDoc

Status

This library is fully stable and is used in production by several companies.

Examples

Super simple to use.

To get a phone number

num, err := libphonenumber.Parse("6502530000", "US")

To format a number

// num is a *libphonenumber.PhoneNumber
formattedNum := libphonenumber.Format(num, libphonenumber.NATIONAL)

To get the area code of a number

// Parse the number.
num, err := libphonenumber.Parse("1234567890", "US")
if err != nil {
        // Handle error appropriately.
}

// Get the cleaned number and the length of the area code.
natSigNumber := libphonenumber.GetNationalSignificantNumber(num)
geoCodeLength := libphonenumber.GetLengthOfGeographicalAreaCode(num)

// Extract the area code.
areaCode := ""
if geoCodeLength > 0 {
        areaCode = natSigNumber[0:geoCodeLength]
}
fmt.Println(areaCode)

About

golang port of Google's libphonenumber

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Makefile 0.1%