Skip to content

show Go package "used by" counts including repository subpackages

Warren Gifford requested to merge go-importers-badge into master

Created by: sqs

Previously, our "used by" badge (for Go packages) would only show the number of other packages using a repository's top-level package, not its subpackages. Now the "used by" badge counts users of its subpackages.

It works as follows:

  • Determine the custom import path (if any) in use by looking for Go import path comments in the repository. We implement this heuristic in our Go language server already, and we can reuse that code.
  • Perform iterated calls to the importers API for each of the (non-vendor, non-internal) Go subpackages in the repository. Sum the result.

The count sums together the user counts of all of the repository's subpackages. This overcounts the number of users, because if another project uses multiple subpackages in this repository, it is counted multiple times. This limitation is now documented and will be addressed in the future.

Fixes some of https://github.com/sourcegraph/sourcegraph/issues/849 (does not implement actually showing the packages that use it).

Merge request reports

Loading