nyaruka / phonenumbers

GoLang port of Google's libphonenumber library
MIT License
1.25k stars 148 forks source link

Get Area Code/Prefix #87

Closed RaMin0 closed 3 years ago

RaMin0 commented 3 years ago

GetCarrierForNumber tries to guess the name of the carrier of a given number. In its implementation, it calls getValueForNumber which in turn attempts to find the "prefix" (or index) of the provided number that exists in carrierMapData.

My question is, is it possible to alter the function to add this "prefix" as an extra return value? It's a requirement in a project I'm working on where the prefix is needed rather than the carrier name. For example:

func getValueForNumber(...) (string, int, error) { // int is for the prefix/index

~I'm happy to create a PR for it if this looks like a good addition to this package.~ I went ahead and created one.

RaMin0 commented 3 years ago

@nicpottier Let's close this?

nicpottier commented 3 years ago

Yep, added in https://github.com/nyaruka/phonenumbers/pull/88, thank you!