首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GoMobile构建:找不到包

GoMobile构建:找不到包
EN

Stack Overflow用户
提问于 2019-08-28 11:14:51
回答 1查看 1K关注 0票数 1

我在Go1.12.9 windows/ and 64中测试了GoMobile工具,并尝试将其附带的示例项目构建到Android中。

在将构建指向目录并运行build命令时,控制台提供了一个无法找到包错误。如何识别Go包裹?

[注意-我试着安装和使用GoMobile工具,但它们也没有被识别,我只能通过VSCode下载它们作为Git包]。

代码语言:javascript
运行
复制
PS D:\Script\Golang\bin> go version
go version go1.12.9 windows/amd64  
PS D:\Script\Golang\src\golang.org\x\mobile\example\basic> gci


    Directory: D:\Script\Golang\src\golang.org\x\mobile\example\basic


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       18-08-2019     11:27           4618 main.go
-a----       18-08-2019     11:27            225 main_x.go


PS D:\Script\Golang\src\golang.org\x\mobile\example\basic> cd D:\Script\Golang\bin
PS D:\Script\Golang\bin> .\gomobile.exe build D:\Script\Golang\src\golang.org\x\mobile\example\basic
D:\Script\Golang\bin\gomobile.exe: cannot find package "D:\\Script\\Golang\\src\\golang.org\\x\\mobile\\example\\basic" in any of:
        c:\go\src\D:\Script\Golang\src\golang.org\x\mobile\example\basic (from $GOROOT)
        D:\Script\Golang\src\D:\Script\Golang\src\golang.org\x\mobile\example\basic (from $GOPATH)
S D:\Script\Golang\bin> .\gomobile.exe build "D:\Script\Golang\src\golang.org\x\mobile\example\basic"
D:\Script\Golang\bin\gomobile.exe: cannot find package "D:\\Script\\Golang\\src\\golang.org\\x\\mobile\\example\\basic" in any of:
        c:\go\src\D:\Script\Golang\src\golang.org\x\mobile\example\basic (from $GOROOT)
        D:\Script\Golang\src\D:\Script\Golang\src\golang.org\x\mobile\example\basic (from $GOPATH) 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-28 16:14:39

Go获取与环境/系统variables.It中提供的GOPATH或GOROOT路径有关的路径引用,查找包的GOPATH/GOROOT中的"src"目录。--这意味着提供绝对包路径将无法工作。

-示例(上述案例)

GOPATH = D:\Script\Golang GOROOT = C:\go 绝对包路径= D:\Script\Golang\src\golang.org\x\mobile\example\basic

在这种情况下,提供绝对包路径将被读取为

GOPATH\D:\Script\Golang\src\golang.org\x\mobile\example\basic GOROOT\D:\Script\Golang\src\golang.org\x\mobile\example\basic

由于戈朗使用GOPATH或GOROOT作为参考,包路径应该是

GOPATH\golang.org\x\mobile\example\basic

Golang将自动在环境变量中使用参考GOPATH,并在其后面附加路径。

因此,在上述情况下,所提供的包裹路径是-

PS D:\Script\Golang\bin> .\gomobile.exe build golang.org\x\mobile\example\basic

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57691111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档