相当于Golang requirements.txt [英] Golang requirements.txt equivalent
问题描述
来自python/django世界,拥有与go/revel等效的requirements.txt之类的东西真是太好了.我怎样才能做到这一点?我知道我可以只写一个requirements.txt文件,然后做类似
Coming from a python/django world, it'd be great to have something like a requirements.txt equivalent for go/revel. How can I do this? I know I can just write a requirements.txt file and then do something like
cat requirements | xargs go get
但是,如果我的需求也有需求怎么办?上面的命令将尝试获取"它们,然后它们将无法构建,因为我没有安装这些要求.
But what if my requirements ALSO have requirements? The above command would attempt to "go get" them, and then they'd fail to build, since I don't have those requirements installed.
有什么我想念的吗?
推荐答案
命令go get
完全满足您的需求:它将找到所有依赖项,并下载并安装缺少的依赖项.专注于"全部":go get
确实遍历了您的依赖关系图.
The command go get
does exactly what you need: It finds all dependencies and downloads and installs the missing ones. Focus on "all": go get
really traverses your dependency graph.
看一下文档:
https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them
Go文档非常简洁,简短且编写得很好.我建议始终在基于其他工具或工具链的经验进行假设之前,先阅读文档.
The Go documentation is really clean, short and well written. I would recommend always to have a look at the documentation first before making assumptions which are based on experience with other tools or tool-chains.
他们还提供有用的博客文章, https://blog.golang.org/using-去模块
They also provide useful blog posts, https://blog.golang.org/using-go-modules
这篇关于相当于Golang requirements.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!