英文:
Compile glide vendored packages
问题
Golang的glide会将依赖项下载到项目的源代码中。因此,go build
命令也会编译这些依赖项,而用于代码检查的go插件也会解析这些依赖项。
假设这些依赖项是稳定的,我该如何编译这些依赖项以加快go build
的速度?
另外,我该如何从go的工具中移除vendor/
目录,以便对代码库进行lint和错误检查?
英文:
Golang's glide downloads dependencies to the project's source. As a result, go build
compiles those too, and go plugins that lint/vet the codebase also parse the dependencies.
Assuming those dependencies are stable, how can I compile the dependencies so go build
becomes faster?
Also, how can I remove vendor/
from go's tools to lint and check the codebase for errors?
答案1
得分: 0
有没有一种方法可以预编译我的依赖项(获取 .a 文件),这样在运行 go install 或 go build 时编译速度会更快?
请参考 https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
go build [-o output] [-i] [build flags] [packages]
[...]
-i 标志会安装目标的依赖包。
此外,如何从 go 的工具中删除 vendor/,以便对代码库进行 lint 和错误检查?
请参考 https://github.com/golang/go/issues/11659#issuecomment-122139338:
不要使用 ./...,可以使用以下命令:
go install $(go list ./... | grep -v /vendor/)
英文:
> Is there a way to pre-compile my dependencies (get .a) files, so it is
> faster to compile when I run go install or go build
See https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
> go build [-o output] [-i] [build flags] [packages]
[...]
> The -i flag installs the packages that are dependencies of the target.
> Also, how can I remove vendor/ from go's tools to lint and check the
> codebase for errors?
See https://github.com/golang/go/issues/11659#issuecomment-122139338:
> Instead of using ./... you can do:
go install $(go list ./... | grep -v /vendor/)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论