Golang 1.11beta2引入了对Modules的实验支持。我无法从go模块中导入特定的程序包。这是构建应用程序时的错误:$ go installgo: downloading github.com/udhos/modhello/modlib/lib v1.0.0go: finding github.com/udhos/modhello latestgo: import "github.com/udhos/modhello/modapp" -> import "github.com/udhos/modhello/modlib/lib": cannot find module providing package github.com/udhos/modhello/modlib/lib为什么上面显示的导入失败?这是来自模块'modlib'的软件包'lib':# repo: modhello# module: modlib# package: lib$ cat modhello/modlib/lib/modlib.gopackage libfunc Sum(a, b int) int { return a + b}$ cat modhello/modlib/go.modmodule github.com/udhos/modhello/modlib这是应用程序“ modapp”:$ cat modhello/modapp/main.gopackage mainimport ( "log" "github.com/udhos/modhello/modlib/lib")func main() { run(1, 2)}func run(a, b int) { log.Printf("Sum(%d,%d) = %d", a, b, lib.Sum(a, b))}$ cat modhello/modapp/go.modmodule github.com/udhos/modhello/modapprequire github.com/udhos/modhello/modlib v1.0.0git存储库标记为“ modlib / v1.0.0”。这就是发布模块版本的方式。转到版本:$ go versiongo version go1.11beta2 linux/amd64$ git --versiongit version 2.18.0我还在golang-nuts上发布了这个疑问:在一个git repo中托管两个不同的模块?
1 回答
- 1 回答
- 0 关注
- 290 浏览
添加回答
举报
0/150
提交
取消