many: allow for multiple documentations for a Unit
Change internal.Unit.Documentation from a single
internal.Documentation to a slice, so that a Unit can have doc for
multiple build contexts.
However, don't use this ability yet: fetch takes only the first
build context it finds, postgres inserts only the first, frontend
renders only the first, etc.
For golang/go#37232
Change-Id: I17fd1ff2378e0862c029c8077057c207001f6136
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288217
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>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/fetch/fetchdata_test.go b/internal/fetch/fetchdata_test.go
index cfa917b..dc7804a 100644
--- a/internal/fetch/fetchdata_test.go
+++ b/internal/fetch/fetchdata_test.go
@@ -53,9 +53,9 @@
Name: "foo",
Path: "github.com/basic/foo",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package foo exports a helpful constant.",
- },
+ }},
Imports: []string{"net/http"},
},
},
@@ -123,18 +123,18 @@
Filepath: "bar/README.md",
Contents: "Another README FILE FOR TESTING.",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package bar",
- },
+ }},
},
{
UnitMeta: internal.UnitMeta{
Name: "foo",
Path: "github.com/my/module/foo",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package foo",
- },
+ }},
Imports: []string{"fmt", "github.com/my/module/bar"},
},
},
@@ -177,9 +177,9 @@
Name: "p",
Path: "no.mod/module/p",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package p is inside a module where a go.mod file hasn't been explicitly added yet.",
- },
+ }},
},
},
},
@@ -240,9 +240,9 @@
Name: "good",
Path: "bad.mod/module/good",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package good is inside a module that has bad packages.",
- },
+ }},
},
},
},
@@ -305,9 +305,9 @@
Name: "cpu",
Path: "build.constraints/module/cpu",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package cpu implements processor feature detection used by the Go standard library.",
- },
+ }},
},
},
},
@@ -396,18 +396,18 @@
Name: "bar",
Path: "nonredistributable.mod/module/bar",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package bar",
- },
+ }},
},
{
UnitMeta: internal.UnitMeta{
Name: "baz",
Path: "nonredistributable.mod/module/bar/baz",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package baz",
- },
+ }},
},
{
UnitMeta: internal.UnitMeta{
@@ -418,9 +418,9 @@
Filepath: "foo/README.md",
Contents: "README FILE SHOW UP HERE BUT WILL BE REMOVED BEFORE DB INSERT",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package foo",
- },
+ }},
Imports: []string{"fmt", "github.com/my/module/bar"},
},
},
@@ -468,7 +468,7 @@
Name: "foo",
Path: "bad.import.path.com/good/import/path",
},
- Documentation: &internal.Documentation{},
+ Documentation: []*internal.Documentation{{}},
},
},
},
@@ -526,9 +526,9 @@
Name: "permalink",
Path: "doc.test/permalink",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package permalink is for testing the heading permalink documentation rendering feature.",
- },
+ }},
},
},
},
@@ -565,9 +565,9 @@
Name: "bigdoc",
Path: "bigdoc.test",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "This documentation is big.",
- },
+ }},
},
},
},
@@ -621,11 +621,11 @@
Name: "js",
Path: "github.com/my/module/js/js",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package js only works with wasm.",
GOOS: "js",
GOARCH: "wasm",
- },
+ }},
},
},
},
@@ -673,9 +673,9 @@
Name: "builtin",
Path: "builtin",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package builtin provides documentation for Go's predeclared identifiers.",
- },
+ }},
},
{
UnitMeta: internal.UnitMeta{
@@ -691,9 +691,9 @@
Filepath: "cmd/pprof/README",
Contents: "This directory is the copy of Google's pprof shipped as part of the Go distribution.\n",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Pprof interprets and displays profiles of Go programs.",
- },
+ }},
Imports: []string{
"cmd/internal/objfile",
"crypto/tls",
@@ -719,9 +719,9 @@
Name: "context",
Path: "context",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.",
- },
+ }},
Imports: []string{"errors", "fmt", "reflect", "sync", "time"},
},
{
@@ -734,9 +734,9 @@
Name: "json",
Path: "encoding/json",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package json implements encoding and decoding of JSON as defined in RFC 7159.",
- },
+ }},
Imports: []string{
"bytes",
"encoding",
@@ -760,9 +760,9 @@
Name: "errors",
Path: "errors",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package errors implements functions to manipulate errors.",
- },
+ }},
},
{
UnitMeta: internal.UnitMeta{
@@ -770,9 +770,9 @@
Path: "flag",
},
Imports: []string{"errors", "fmt", "io", "os", "reflect", "sort", "strconv", "strings", "time"},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package flag implements command-line flag parsing.",
- },
+ }},
},
},
},
@@ -806,9 +806,9 @@
Name: "foo",
Path: "github.com/my/module/foo",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package foo exports a helpful constant.",
- },
+ }},
},
},
},
@@ -842,9 +842,9 @@
Name: "foo",
Path: "github.com/my/module/foo",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package foo exports a helpful constant.",
- },
+ }},
},
},
},
@@ -891,9 +891,9 @@
Name: "example",
Path: path + "/example",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package example contains examples.",
- },
+ }},
},
},
},
diff --git a/internal/fetch/helper_test.go b/internal/fetch/helper_test.go
index 1196d19..b03c934 100644
--- a/internal/fetch/helper_test.go
+++ b/internal/fetch/helper_test.go
@@ -73,10 +73,10 @@
IsRedistributable: u.IsRedistributable,
Licenses: u.Licenses,
}
- if u.Documentation != nil {
- if u.Documentation.GOOS == "" {
- u.Documentation.GOOS = "linux"
- u.Documentation.GOARCH = "amd64"
+ if len(u.Documentation) > 0 {
+ if u.Documentation[0].GOOS == "" {
+ u.Documentation[0].GOOS = "linux"
+ u.Documentation[0].GOARCH = "amd64"
}
}
if u.IsPackage() && shouldSetPVS {
diff --git a/internal/fetch/unit.go b/internal/fetch/unit.go
index 7bce5bb..4e8d5b3 100644
--- a/internal/fetch/unit.go
+++ b/internal/fetch/unit.go
@@ -62,7 +62,7 @@
dir.Name = pkg.name
dir.Imports = pkg.imports
// TODO(golang/go#37232): keep all docs
- dir.Documentation = pkg.docs[0]
+ dir.Documentation = pkg.docs[:1]
}
units = append(units, dir)
}
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index 005e358..2b3ecec 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -42,12 +42,12 @@
Version: "v1.0.0",
IsRedistributable: true,
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
GOOS: sample.GOOS,
GOARCH: sample.GOARCH,
Synopsis: "foo is a package.",
Source: []byte{},
- },
+ }},
Readme: &internal.Readme{
Filepath: "readme",
Contents: "readme",
@@ -73,12 +73,12 @@
Version: "v1.0.0",
IsRedistributable: true,
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
GOOS: sample.GOOS,
GOARCH: sample.GOARCH,
Synopsis: "bar is used by foo.",
Source: []byte{},
- },
+ }},
Readme: &internal.Readme{
Filepath: "readme",
Contents: "readme",
@@ -116,7 +116,7 @@
Name: moduleBar.Packages()[0].Name,
PackagePath: moduleBar.Packages()[0].Path,
ModulePath: moduleBar.ModulePath,
- Synopsis: moduleBar.Packages()[0].Documentation.Synopsis,
+ Synopsis: moduleBar.Packages()[0].Documentation[0].Synopsis,
DisplayVersion: moduleBar.Version,
Licenses: []string{"MIT"},
CommitTime: elapsedTime(moduleBar.CommitTime),
@@ -142,7 +142,7 @@
Name: moduleFoo.Packages()[0].Name,
PackagePath: moduleFoo.Packages()[0].Path,
ModulePath: moduleFoo.ModulePath,
- Synopsis: moduleFoo.Packages()[0].Documentation.Synopsis,
+ Synopsis: moduleFoo.Packages()[0].Documentation[0].Synopsis,
DisplayVersion: moduleFoo.Version,
Licenses: []string{"MIT"},
CommitTime: elapsedTime(moduleFoo.CommitTime),
diff --git a/internal/frontend/unit_main.go b/internal/frontend/unit_main.go
index dc72eac..bafb16d 100644
--- a/internal/frontend/unit_main.go
+++ b/internal/frontend/unit_main.go
@@ -166,9 +166,9 @@
synopsis string
)
if unit.Documentation != nil {
- synopsis = unit.Documentation.Synopsis
+ synopsis = unit.Documentation[0].Synopsis
end := middleware.ElapsedStat(ctx, "DecodePackage")
- docPkg, err := godoc.DecodePackage(unit.Documentation.Source)
+ docPkg, err := godoc.DecodePackage(unit.Documentation[0].Source)
end()
if err != nil {
if errors.Is(err, godoc.ErrInvalidEncodingType) {
@@ -343,7 +343,7 @@
func getHTML(ctx context.Context, u *internal.Unit, docPkg *godoc.Package) (_ *dochtml.Parts, err error) {
defer derrors.Wrap(&err, "getHTML(%s)", u.Path)
- if len(u.Documentation.Source) > 0 {
+ if len(u.Documentation[0].Source) > 0 {
return renderDocParts(ctx, u, docPkg)
}
log.Errorf(ctx, "unit %s (%s@%s) missing documentation source", u.Path, u.ModulePath, u.Version)
diff --git a/internal/frontend/versions_test.go b/internal/frontend/versions_test.go
index 4d10686..ae88ed8 100644
--- a/internal/frontend/versions_test.go
+++ b/internal/frontend/versions_test.go
@@ -61,7 +61,7 @@
"v1.2.1",
sample.Suffix,
true),
- Documentation: sample.Documentation,
+ Documentation: []*internal.Documentation{sample.Documentation},
}
pkg2 := &internal.Unit{
UnitMeta: *sample.UnitMeta(
@@ -70,7 +70,7 @@
"v1.2.1-alpha.1",
sample.Suffix,
true),
- Documentation: sample.Documentation,
+ Documentation: []*internal.Documentation{sample.Documentation},
}
nethttpPkg := &internal.Unit{
UnitMeta: *sample.UnitMeta(
@@ -79,7 +79,7 @@
"v1.12.5",
"http",
true),
- Documentation: sample.Documentation,
+ Documentation: []*internal.Documentation{sample.Documentation},
}
makeList := func(pkgPath, modulePath, major string, versions []string) *VersionList {
return &VersionList{
diff --git a/internal/godoc/render.go b/internal/godoc/render.go
index cc703bd..42ffe6a 100644
--- a/internal/godoc/render.go
+++ b/internal/godoc/render.go
@@ -180,7 +180,7 @@
// RenderPartsFromUnit is a convenience function that first decodes the source
// in the unit, which must exist, and then calls RenderParts.
func RenderPartsFromUnit(ctx context.Context, u *internal.Unit) (_ *dochtml.Parts, err error) {
- docPkg, err := DecodePackage(u.Documentation.Source)
+ docPkg, err := DecodePackage(u.Documentation[0].Source)
if err != nil {
return nil, err
}
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go
index f629187..a241fc1 100644
--- a/internal/postgres/insert_module.go
+++ b/internal/postgres/insert_module.go
@@ -328,10 +328,14 @@
if u.Readme != nil {
pathToReadme[u.Path] = u.Readme
}
- if u.Documentation != nil && u.Documentation.Source == nil {
+ if u.Documentation != nil && u.Documentation[0] != nil && u.Documentation[0].Source == nil {
return fmt.Errorf("insertUnits: unit %q missing source files", u.Path)
}
- pathToDoc[u.Path] = u.Documentation
+ if u.Documentation == nil {
+ pathToDoc[u.Path] = nil
+ } else {
+ pathToDoc[u.Path] = u.Documentation[0]
+ }
if len(u.Imports) > 0 {
pathToImports[u.Path] = u.Imports
}
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index b290af5..617e775 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -129,7 +129,7 @@
}
mod := sample.Module(sample.ModulePath, sample.VersionString, "")
- checkHasRedistData(mod.Units[0].Readme.Contents, mod.Units[0].Documentation.Source, true)
+ checkHasRedistData(mod.Units[0].Readme.Contents, mod.Units[0].Documentation[0].Source, true)
mod.IsRedistributable = false
mod.Units[0].IsRedistributable = false
@@ -155,7 +155,7 @@
readme = u.Readme.Contents
}
if u.Documentation != nil {
- source = u.Documentation.Source
+ source = u.Documentation[0].Source
}
checkHasRedistData(readme, source, bypass)
})
diff --git a/internal/postgres/search.go b/internal/postgres/search.go
index f8ce3b5..decba91 100644
--- a/internal/postgres/search.go
+++ b/internal/postgres/search.go
@@ -464,8 +464,9 @@
PackagePath: pkg.Path,
ModulePath: mod.ModulePath,
}
- if pkg.Documentation != nil {
- args.Synopsis = pkg.Documentation.Synopsis
+ if len(pkg.Documentation) > 0 {
+ // Use the synopsis of the first GOOS/GOARCH pair.
+ args.Synopsis = pkg.Documentation[0].Synopsis
}
if pkg.Readme != nil {
args.ReadmeFilePath = pkg.Readme.Filepath
diff --git a/internal/postgres/search_test.go b/internal/postgres/search_test.go
index 1a830ec..db41c98 100644
--- a/internal/postgres/search_test.go
+++ b/internal/postgres/search_test.go
@@ -156,7 +156,7 @@
m := sample.Module(popularPath, "v1.2.3", "")
m.Packages()[0].Imports = nil
// Try to improve the ts_rank of the 'foo' search term.
- m.Packages()[0].Documentation.Synopsis = "foo"
+ m.Packages()[0].Documentation[0].Synopsis = "foo"
m.Units[0].Readme.Contents = "foo"
mods := []*internal.Module{m}
@@ -167,12 +167,12 @@
fullPath := importerModule + "/" + name
u := &internal.Unit{
UnitMeta: *sample.UnitMeta(fullPath, importerModule, m.Version, name, true),
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: sample.Synopsis,
GOOS: sample.GOOS,
GOARCH: sample.GOARCH,
Source: []byte{},
- },
+ }},
Imports: []string{popularPath},
}
sample.AddUnit(m, u)
@@ -418,12 +418,12 @@
Path: "gocloud.dev/cloud",
IsRedistributable: true, // required because some test cases depend on the README contents
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
GOOS: sample.GOOS,
GOARCH: sample.GOARCH,
Synopsis: "Package cloud contains a library and tools for open cloud development in Go. The Go Cloud Development Kit (Go CDK)",
Source: []byte{},
- },
+ }},
}
modKube = "k8s.io"
@@ -433,19 +433,19 @@
Path: "k8s.io/client-go",
IsRedistributable: true, // required because some test cases depend on the README contents
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
GOOS: sample.GOOS,
GOARCH: sample.GOARCH,
Synopsis: "Package client-go implements a Go client for Kubernetes.",
Source: []byte{},
- },
+ }},
}
kubeResult = func(score float64, numResults uint64) *internal.SearchResult {
return &internal.SearchResult{
Name: pkgKube.Name,
PackagePath: pkgKube.Path,
- Synopsis: pkgKube.Documentation.Synopsis,
+ Synopsis: pkgKube.Documentation[0].Synopsis,
Licenses: []string{"MIT"},
CommitTime: sample.CommitTime,
Version: sample.VersionString,
@@ -459,7 +459,7 @@
return &internal.SearchResult{
Name: pkgGoCDK.Name,
PackagePath: pkgGoCDK.Path,
- Synopsis: pkgGoCDK.Documentation.Synopsis,
+ Synopsis: pkgGoCDK.Documentation[0].Synopsis,
Licenses: []string{"MIT"},
CommitTime: sample.CommitTime,
Version: sample.VersionString,
@@ -767,7 +767,7 @@
insertModule := func(version string, gomod bool) {
m := sample.Module(sample.ModulePath, version, "A")
m.HasGoMod = gomod
- m.Packages()[0].Documentation.Synopsis = "syn-" + version
+ m.Packages()[0].Documentation[0].Synopsis = "syn-" + version
if err := testDB.InsertModule(ctx, m); err != nil {
t.Fatal(err)
}
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go
index 0e205cd..97044f5 100644
--- a/internal/postgres/unit.go
+++ b/internal/postgres/unit.go
@@ -400,7 +400,7 @@
return nil, derrors.NotFound
case nil:
if d.GOOS != "" {
- u.Documentation = &d
+ u.Documentation = []*internal.Documentation{&d}
}
if r.Filepath != "" {
u.Readme = &r
diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go
index 0a7ef99..9a2a73c 100644
--- a/internal/postgres/unit_test.go
+++ b/internal/postgres/unit_test.go
@@ -626,7 +626,7 @@
cleanFields := func(u *internal.Unit, fields internal.FieldSet) {
// Add/remove fields based on the FieldSet specified.
if fields&internal.WithMain != 0 {
- u.Documentation = sample.Documentation
+ u.Documentation = []*internal.Documentation{sample.Documentation}
u.Readme = readme
u.NumImports = len(sample.Imports)
u.Subdirectories = []*internal.PackageMeta{
@@ -714,7 +714,7 @@
if u.IsPackage() {
u.Imports = sample.Imports
u.NumImports = len(sample.Imports)
- u.Documentation = sample.Documentation
+ u.Documentation = []*internal.Documentation{sample.Documentation}
}
return u
}
diff --git a/internal/proxydatasource/datasource_test.go b/internal/proxydatasource/datasource_test.go
index bf52d1d..a0a8001 100644
--- a/internal/proxydatasource/datasource_test.go
+++ b/internal/proxydatasource/datasource_test.go
@@ -78,11 +78,11 @@
IsRedistributable: true,
},
Imports: []string{"net/http"},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package baz provides a helpful constant.",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
}
wantModuleInfo = internal.ModuleInfo{
ModulePath: "foo.com/bar",
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index 0376d70..4df0df6 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -140,12 +140,12 @@
func UnitForPackage(path, modulePath, version, name string, isRedistributable bool) *internal.Unit {
return &internal.Unit{
UnitMeta: *UnitMeta(path, modulePath, version, name, isRedistributable),
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: Synopsis,
Source: DocumentationSource,
GOOS: GOOS,
GOARCH: GOARCH,
- },
+ }},
LicenseContents: Licenses,
Imports: Imports,
NumImports: len(Imports),
diff --git a/internal/unit.go b/internal/unit.go
index 82a116f..3a1a36a 100644
--- a/internal/unit.go
+++ b/internal/unit.go
@@ -51,7 +51,7 @@
type Unit struct {
UnitMeta
Readme *Readme
- Documentation *Documentation
+ Documentation []*Documentation
Subdirectories []*PackageMeta
Imports []string
LicenseContents []*licenses.License
diff --git a/internal/worker/fetch_test.go b/internal/worker/fetch_test.go
index 6c85e77..2a41105 100644
--- a/internal/worker/fetch_test.go
+++ b/internal/worker/fetch_test.go
@@ -155,11 +155,11 @@
{Types: []string{"MIT"}, FilePath: "bar/LICENSE"},
},
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package bar",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
Readme: &internal.Readme{
Filepath: "bar/README.md",
Contents: "README FILE FOR TESTING.",
@@ -209,11 +209,11 @@
{Types: []string{"MIT"}, FilePath: "bar/baz/COPYING"},
},
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "package baz",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
},
wantDoc: []string{"Baz returns the string "baz"."},
}, {
@@ -259,11 +259,11 @@
},
},
NumImports: 5,
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
},
wantDoc: []string{"This example demonstrates the use of a cancelable context to prevent a\ngoroutine leak."},
}, {
@@ -287,11 +287,11 @@
},
},
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package builtin provides documentation for Go's predeclared identifiers.",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
},
wantDoc: []string{"int64 is the set of all signed 64-bit integers."},
}, {
@@ -316,11 +316,11 @@
},
},
NumImports: 15,
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package json implements encoding and decoding of JSON as defined in RFC 7159.",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
},
wantDoc: []string{
"The mapping between JSON and Go values is described\nin the documentation for the Marshal and Unmarshal functions.",
@@ -353,11 +353,11 @@
{Types: []string{"0BSD"}, FilePath: "LICENSE"},
},
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package cpu implements processor feature detection used by the Go standard library.",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
},
wantDoc: []string{"const CacheLinePadSize = 3"},
dontWantDoc: []string{
@@ -399,7 +399,7 @@
t.Errorf("mismatch on readme (-want +got):\n%s", diff)
}
if got, want := gotPkg.Documentation, test.want.Documentation; got == nil || want == nil {
- if got != want {
+ if !cmp.Equal(got, want) {
t.Fatalf("mismatch on documentation: got: %v\nwant: %v", got, want)
}
return
diff --git a/internal/worker/refetch_test.go b/internal/worker/refetch_test.go
index a5a6f57..0bf54fa 100644
--- a/internal/worker/refetch_test.go
+++ b/internal/worker/refetch_test.go
@@ -100,11 +100,11 @@
Filepath: "bar/README.md",
Contents: "This is a readme",
},
- Documentation: &internal.Documentation{
+ Documentation: []*internal.Documentation{{
Synopsis: "Package bar",
GOOS: "linux",
GOARCH: "amd64",
- },
+ }},
Subdirectories: []*internal.PackageMeta{
{
Path: "github.com/valid/module_name/bar",
@@ -138,7 +138,7 @@
t.Errorf("mismatch on readme (-want +got):\n%s", diff)
}
if got, want := gotPkg.Documentation, want.Documentation; got == nil || want == nil {
- if got != want {
+ if !cmp.Equal(got, want) {
t.Fatalf("mismatch on documentation: got: %v\nwant: %v", got, want)
}
return