8000 Process import comments properly · Issue #902 · golang/dep · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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.
Process import comments properly #902
Closed
@sdboyer

Description

@sdboyer

Go 1.4 introduced support for declaring canonical import paths via import comments. Now, TIL that these import comments are ignored by the compiler when within a vendor/ directory, so we could disregard them. But that seems unwise. Given that we view vendor/ as an implementation detail, there's a time in the foreseeable future where the compiler may start enforcing these comments again, and we should enforce them in order for our generated lock files to be maximally forwards-compatible.

Beyond this practical reason, import comments are a useful bit of information that establish internal identity and canonicality for code locations in a world where identity is otherwise entirely determined by the importer/addresser. That makes them a very useful signal, and we should take advantage of it.

The place where this information needs to enter the system is in pkgtree.ListPackages(); the processing work itself is done in pkgtree.fillPackage(). We'll need:

  1. Basic error coverage, in the event that a single package has multiple, incompatible import comments. We'll need to make our own type for this, as we can't reuse whatever go/build does (it's not exported, may not even exist as a type).
  2. Validation that the import comment aligns as expected with the importRoot argument to pkgtree.ListPackages(). This'll definitely require a new error type.
  3. New tests that cover all possibilities, happy and not, codified via new fixtures under internal/gps/_testdata/src and utilized in TestListPackages().

Note that changing this will probably entail bumping the solver version (the number in Gopkg.lock). It's our first time doing that, so we'll need to plan a little bit around it. In a follow-up issue, we can modify the solver to incorporate a new satisfiability check that the import comment data is respected.

/cc @ChimeraCoder

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0