简体   繁体   English

如何在 Go 中导入具有特殊分支的库

[英]How to import a library with a special branch in Go

I am new for Go, and I am working on the project which need importing internal library.我是 Go 的新手,我正在做需要导入内部库的项目。 I can use go get to import it, and it works very well.我可以使用 go get 来导入它,而且效果很好。 So I noticed that running go get, it will import the master branch.所以我注意到运行 go get,它会导入 master 分支。 However, I have a special case, that I need to import a dev branch instead of master branch.但是,我有一个特殊情况,我需要导入 dev 分支而不是 master 分支。 After doing some research, I tried go get libraryUrl@branchName, and it does not work for me.在做了一些研究之后,我尝试了 go get libraryUrl@branchName,但它对我不起作用。 Any idea how to do it?知道怎么做吗? Here is my go mod info这是我的 go 模组信息

module projectName
go 1.15
require(
     github.com/satori/go.uuid v1.2.0
     internal libraryURL v0.01
)

Thank you for the help.感谢您的帮助。 And let me know if you need more info.如果您需要更多信息,请告诉我。

Thank to @blackgreen, who give me a link regarding this problem.感谢@blackgreen,他给了我一个关于这个问题的链接。 I post here for someone who met the same problem as me.我在这里为遇到与我相同问题的人发帖。 The conclusion is if go get libraryUrl@branchName doesn't work for you, set up the go env -w GO111MODULE=on.结论是如果 go get libraryUrl@branchName 对您不起作用,请设置 go env -w GO111MODULE=on。 Then it shall work.然后它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM