Search code examples
godependenciesvendorgolint

Compile glide vendored packages


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?


Solution

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