Golang libphonenumber

标签 go libphonenumber

<分区>

如何通过使用此库在 golang 中传递数字来获取国家代码: https://godoc.org/github.com/nyaruka/phonenumbers

最佳答案

我正在寻找的答案是如何通过仅传递电话号码来获取国家代码,这是完美运行的解决方案。

num, err := phonenumbers.Parse("+123456789", "")

if err != nil {
    fmt.Println(err.Error())
}

regionNumber := phonenumbers.GetRegionCodeForNumber(num)
countryCode := phonenumbers.GetCountryCodeForRegion(regionNumber)
fmt.Println(countryCode)

谢谢 Yacacov 的提示 ;)

关于Golang libphonenumber,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55010028/

相关文章:

go - interface{} 到函数类型转换

types - Go 类型转换和未导出的 CGo 类型

golang 强制对特定 ip 的 http 请求(类似于 curl --resolve)

angular - 在 Angular react 形式验证器中使用 google-libphonenumber

json - Golang 中的类型转换

go - 等待 gin HTTP 服务器启动

javascript - libphonenumber(google 和 libphonenumber-js)库可以在中国使用吗?

android - 如何在Android中使用libphonenumber api从手机号码中获取国家代码

grails - 是否可以以编程方式区分美国和加拿大的电话号码?

ios - 在 iOS 上使用 libPhoneNumber 列出所有国家/地区的代码和调用代码