编译Glide的vendored包。

huangapple go评论75阅读模式
英文:

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/)

huangapple
  • 本文由 发表于 2015年11月13日 16:41:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/33688705.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定