Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 戈朗李白电话号码_Go_Libphonenumber - Fatal编程技术网

Go 戈朗李白电话号码

Go 戈朗李白电话号码,go,libphonenumber,Go,Libphonenumber,我如何通过使用此库传递golang中的号码来获取国家代码: ?我一直在寻找的答案是如何通过只传递电话号码来获取国家代码,这是一个非常有效的解决方案 num, err := phonenumbers.Parse("+123456789", "") if err != nil { fmt.Println(err.Error()) } regionNumber := phonenumbers.GetRegionCodeForNumber(num) countryCode := phonen

我如何通过使用此库传递golang中的号码来获取国家代码:

我一直在寻找的答案是如何通过只传递电话号码来获取国家代码,这是一个非常有效的解决方案

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

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

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

谢谢亚卡科夫的提示;)

您没有编写语法上有效的Go。大多数基本语法问题都会在中得到回答,只需几分钟即可完成。看起来这是一个Java库的机器生成端口,包含Java示例。这就是它不起作用的原因——您试图用Go编写Java。我知道语法对golang无效,但这是我在库文档中发现的:,我只是golang的初学者,这就是为什么我认为我可能遗漏了一些东西。那么您的问题是什么?你似乎在问为什么那个代码不起作用。