英文:
Importing Go packages locally rather than remotely
问题
在一个Node.js项目中,我正在使用Go来处理Node无法处理的关键部分。我想将Go代码分成一个sockets
包和一个main
包,其中sockets
包含main
包运行所需的结构体/接口。我遇到的问题是,根据我从Go的文档中了解到的,我只能从github/gopkg等地方使用像sockets
这样的外部包。我不想将项目的存储库分成一个包含Go代码的存储库和一个包含Node代码的存储库。我该如何使sockets
包在本地可供main
导入,同时又能够在源代码更新时重新构建这两个包的二进制文件呢?
编辑:导入包不再是问题,但在更新时重新构建包仍然存在。
英文:
In a node.js project, I'm using Go for a critical part of it that node isn't adequate enough to handle. I want to split the Go code into a sockets
package and a main
package, with sockets
containing required structs/interfaces for the main
package to run. The problem I'm having is that from what I can gather from Go's documentation, I can only use external packages like sockets
remotely from github/gopkg. I don't want to split the repository for the project into one containing the Go code and one containing node's. How can I make the sockets
package available for main
to import locally while making it possible to rebuild the binaries for the two packages if any updates to their source code are made?
Edit: importing the packages is no longer an issue, but rebuilding packages on update still remains
答案1
得分: 1
这也发生在我的团队身上,我们最终使用了供应商(vendor)来管理所有的外部包,这样任何检出你的仓库的人都会在供应商文件夹中找到所有的包。
了解和使用供应商文件夹:Understanding and using the vendor folder
此外,请参考这个网站,还有很多其他选项可供选择:Golang Package Management Tools
英文:
It happens the same to my team too and we end up using vendor it's pretty easy to manage all the external packages. So, whoever checkout your repo will have all the packages inside vendor.
Understanding and using the vendor folder
And Please refer this site lots of other option out there too:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论