Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ttacon/libphonenumber
golang port of Google's libphonenumber
https://github.com/ttacon/libphonenumber
Last synced: 4 months ago
JSON representation
golang port of Google's libphonenumber
- Host: GitHub
- URL: https://github.com/ttacon/libphonenumber
- Owner: ttacon
- License: mit
- Created: 2014-12-27T04:11:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-29T08:27:40.000Z (5 months ago)
- Last Synced: 2024-01-31T03:30:51.628Z (5 months ago)
- Language: Go
- Size: 2.05 MB
- Stars: 596
- Watchers: 11
- Forks: 103
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Lists
- docsify-awesome-stars - ttacon/libphonenumber - golang port of Google's libphonenumber (Go)
- awesome-stars - libphonenumber - golang port of Google's libphonenumber (Go)
README
libphonenumber
==============golang port of Google's libphonenumber
[![forthebadge](http://forthebadge.com/images/badges/no-ragrets.svg)](http://forthebadge.com)
[![Build Status](https://travis-ci.org/ttacon/libphonenumber.svg?branch=master)](https://travis-ci.org/ttacon/libphonenumber)
[![GoDoc](https://godoc.org/github.com/ttacon/libphonenumber?status.png)](https://godoc.org/github.com/ttacon/libphonenumber)Status
======This library is fully stable and is used in production by several companies.
Examples
========Super simple to use.
### To get a phone number
```go
num, err := libphonenumber.Parse("6502530000", "US")
```### To format a number
```go
// num is a *libphonenumber.PhoneNumber
formattedNum := libphonenumber.Format(num, libphonenumber.NATIONAL)
```### To get the area code of a number
```go
// 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)
```