internal/source: support example.com domain for testing

For golang/go#44214

Change-Id: I70a3cbfa62cc051949437ecba94b8667d12dff3e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290896
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
This commit is contained in:
Jonathan Amsterdam 2021-02-10 16:43:34 -05:00
Родитель b10ab3f178
Коммит 169a49f51b
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -260,6 +260,13 @@ func ModuleInfo(ctx context.Context, client *Client, modulePath, version string)
ctx, span := trace.StartSpan(ctx, "source.ModuleInfo")
defer span.End()
// The example.com domain can never be real; it is reserved for testing
// (https://en.wikipedia.org/wiki/Example.com). Treat it as if it used
// GitHub templates.
if strings.HasPrefix(modulePath, "example.com/") {
return NewGitHubInfo("https://"+modulePath, "", version), nil
}
if modulePath == stdlib.ModulePath {
return newStdlibInfo(version)
}