英文:
Gomobile no exported names in the package
问题
我正在尝试将以下代码与gomobile绑定,以便将其导出为iOS的框架。我以前成功地做过这个,但由于某种原因,当我运行绑定命令时,下面的代码会给我一个错误信息:gomobile: no exported names in the package。当作为Go脚本运行时,代码是有效的。
package request
import (
"net/url"
"fmt"
)
func requestEndpoint(number string) string {
safeNumber := url.QueryEscape(number)
url := fmt.Sprintf("http://apilayer.net/api/validate?access_key=690a581e85900555754fd7bfa70808b2&number=%s&country_code=&format=1", safeNumber)
return url
}
有什么想法吗?谢谢!
英文:
I am trying to bind the following code with gomobile to export it as a framework for iOS. I have done this before successfully but for some reason the following code, when I run the bind command gives me the error gomobile: no exported names in the package . The code works when ran as a go script.
package request
import (
"net/url"
"fmt"
)
func requestEndpoint(number string) string {
safeNumber := url.QueryEscape(number)
url := fmt.Sprintf("http://apilayer.net/api/validate?access_key=690a581e85900555754fd7bfa70808b2&number=%s&country_code=&format=1", safeNumber)
return url
}
Any ideas?
Thanks!
答案1
得分: 6
函数requestEndpoint
应该改为RequestEndpoint
。首字母大写的函数被认为是在包中导出的。
英文:
Function requestEndpoint
should be changed to RequestEndpoint
. The capitalized function is considered as exported within the package.
答案2
得分: -1
你应该尝试使用以下命令进行绑定:
$ gomobile bind -target=ios
然后使用以下命令在Request.framework
目录下搜索request
:
$ grep request ./Request.framework/*
英文:
You should try
<p>$ gomobile bind -target=ios</p>
$ grep request ./Request.framework/*
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论