Gomobile包中没有导出的名称。

huangapple go评论77阅读模式
英文:

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/*

huangapple
  • 本文由 发表于 2017年1月25日 16:52:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/41847117.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定