aboutsummaryrefslogtreecommitdiff
path: root/internal/testing/sample/sample.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-10-25 21:57:05 -0400
committerJulie Qiu <julie@golang.org>2020-10-26 13:05:42 +0000
commit4cc0821bb243163181a08cece97be19cf8f832f9 (patch)
treec226d07fbe4c932c8e42a048bef0b74793448a5b /internal/testing/sample/sample.go
parentc4e44bdaacbd99881378c8b055ee9031f182484f (diff)
downloadgo-x-pkgsite-4cc0821bb243163181a08cece97be19cf8f832f9.tar.xz
internal/testing/sample: remove LegacyAddPackage
LegacyAddPackage is removed. AddPackage is used instead where applicable. For golang/go#39629 Change-Id: I61741f8c5c55fb173521b2fdd06259064d77270b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265003 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/testing/sample/sample.go')
-rw-r--r--internal/testing/sample/sample.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index 45b3e88a..b0a16068 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -114,27 +114,17 @@ func UnitForPackage(path, modulePath, version, name string, isRedistributable bo
}
}
-func AddPackage(m *internal.Module, fullPath string) *internal.Module {
- if m.ModulePath != stdlib.ModulePath && !strings.HasPrefix(fullPath, m.ModulePath) {
+func AddPackage(m *internal.Module, pkg *internal.Unit) *internal.Module {
+ if m.ModulePath != stdlib.ModulePath && !strings.HasPrefix(pkg.Path, m.ModulePath) {
panic(fmt.Sprintf("package path %q not a prefix of module path %q",
- fullPath, m.ModulePath))
+ pkg.Path, m.ModulePath))
}
- AddUnit(m, &internal.Unit{
- UnitMeta: *UnitMeta(fullPath, m.ModulePath, m.Version, path.Base(fullPath), true),
- Imports: Imports,
- LicenseContents: Licenses,
- Documentation: &internal.Documentation{
- Synopsis: Synopsis,
- HTML: DocumentationHTML,
- GOOS: GOOS,
- GOARCH: GOARCH,
- },
- })
+ AddUnit(m, UnitForPackage(pkg.Path, m.ModulePath, m.Version, pkg.Name, pkg.IsRedistributable))
minLen := len(m.ModulePath)
if m.ModulePath == stdlib.ModulePath {
minLen = 1
}
- for pth := fullPath; len(pth) > minLen; pth = path.Dir(pth) {
+ for pth := pkg.Path; len(pth) > minLen; pth = path.Dir(pth) {
found := false
for _, u := range m.Units {
if u.Path == pth {