This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve redirection to canonical import path
Problem: Our GitHub organisation is named Teamwork, but for various hard to change reasons we import packages as teamwork (lower case t). To enforce this we add an import enforcement for our packages: package duck // import "github.com/teamwork/duck" This works well, but godoc.org enforces users to use the canonical GitHub path (Teamwork), but with the import statement the Go compiler enforces a different path, leading to an error. Fix: Instead of immediately redirecting in the gosrc package, it will now only store the canonical import path there. This is before the Go source code is actually scanned, so we don't *actually* know what the real canonical path should be. In the doc.newPackage() function it will check for the canonical import path, taking both the Go import path as well as the reported path from the gosrc package in to account, and redirect as needed. This seems to work for all the cases I can think of: github.com/Teamwork/validate -> github.com/teamwork/validate github.com/pkg/ERRORS -> github.com/pkg/errors github.com/Carpetsmoker/sconfig -> arp242.net/sconfig arp242.net/SCONFIG -> not found (expected) bitbucket.org/pkg/inflect -> works bitbucket.org/pkg/INFLECT -> works (should probably redirect too) github.com/docker/docker/client -> works (#534) github.com/moby/moby/client -> redirects (on master this actually seems to error out?) It should also be easy to add a similar check for for some other repo providers, such as BitBucket, GitLab, etc. Fixes #507 Change-Id: I49c5ccb328694f95dd7a0e5d577297d56d88893f GitHub-Last-Rev: 28efc37 GitHub-Pull-Request: #560 Reviewed-on: https://go-review.googlesource.com/120059 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
- Loading branch information