Closed ainsleyclark closed 6 days ago
@ainsleyclark Which function did you call, and what were the results?
Hi @dongri
func FormatTelephone(number string) (string, error) {
if number == "" {
return "", errors.New("telephone cannot be empty")
}
c := phonenumber.GetISO3166ByNumber(number, true)
tel := phonenumber.ParseWithLandLine(number, c.Alpha3)
return formatInternal(number, tel)
}
@ainsleyclark This library provides several features, but it seems that GetISO3166ByNumber
does not work well with landline numbers.
You might want to write it like this:
tel := phonenumber.ParseWithLandLine("07933846223", "GB")
Thanks @dongri
I don't have access the callers country though, just the number. Is there another workaround?
Thanks again.
I added a function to retrieve the country from a mobile number. https://github.com/dongri/phonenumber/blob/main/examples/main.go#L10 Can use v0.1.7
Thanks for your reply.
If I don't know if it's a mobile or landline what would you suggest?
If there is no country code attached, I think it would be difficult to determine the number with just a landline.
Thanks for your reply, is there a way to determine if a given input is a mobile number?
As far as I know, if there is no country code, I think it is impossible to determine.
It's common for the
UK
mobiles to start with07
. For example:07933846223
But it seems that
Gabon
already has this.This results in default country code
17933846223