Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

FAQ recommendation for testing dependencies doesn't work #1768

Closed
@jsternberg

Description

@jsternberg

This is a general comment about the FAQ. The FAQ has a section about testing a dependency and this recommendation doesn't work:

https://golang.github.io/dep/docs/FAQ.html#how-do-i-test-changes-to-a-dependency

I have two projects. One project depends on another project. Both projects utilize the same dependency. This is pretty common. If you use something like a custom logging type and the logging type is in a third package, both dependencies will likely use it.

For clarity, I'm going to give my specific example using influxdb since that's the primary project I work on. We have a library for the language, influxql. influxdb is locked to require a specific revision of influxql and the enterprise version is intended to inherit the version from influxdb so they depend on the same version without too much of a fuss.

If I want to modify influxdb to test it in the enterprise version before submitting a pull request, the FAQ recommends that I delete vendor/github.com/influxdata/influxdb from the enterprise directory and modify the dependency in the GOPATH instead. When I try this, because both projects use dep, I get a type mismatch because the vendored dependencies of influxdb have now become the arguments that need to be passed into the functions. This is the same reason why dep will strip vendor directories when it is vendoring projects because Go doesn't consider these structs equivalent.

To get to this point, here are the commands I have run:

[influxdb] $ dep ensure
[influxdb-enterprise] $ dep ensure
[influxdb-enterprise] $ rm -r vendor/github.com/influxdata/influxdb
[influxdb-enterprise] $ go install ./cmd/...

So I try to delete the vendor directory from the project on the GOPATH so that it is not using its own vendored dependencies since those would need to be stripped out.

[influxdb] $ rm -r vendor/
[influxdb-enterprise] $ go install ./cmd/...

This still fails because now influxdb isn't using any of the vendored dependencies and it tries to use an old version of influxql that happens to be on my path. This is because the dependencies vendored for enterprise aren't globally used as transitive dependencies for the direct dependencies since the vendor folder only applies to code compiled within the enterprise directory. Since the dependency is no longer vendored inside of enterprise, it can't find the locked versions.

Is there any advice for this type of situation? I imagine that this situation will be common and it seems the only way to deal with it is to manually go to each project and do git checkout on the needed revision since you can't use the vendor folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions