internal/frontend: omit cmd packages from /std
Packages in cmd/ are now omitted from the directory listing on
pkg.go.dev/std, as in the case of golang.org/pkg.
For golang/go#44356
Trust: Julie Qiu
@@ -10,6 +10,7 @@ import (
"strings"
"golang.org/x/pkgsite/internal"
+ "golang.org/x/pkgsite/internal/stdlib"
)
// UnitDirectory is the union of nested modules and subdirectories for a
@@ -116,6 +117,12 @@ func getSubdirectories(um *internal.UnitMeta, pkgs []*internal.PackageMeta) []*S
if um.Path == pm.Path {
continue
}
+ if um.Path == stdlib.ModulePath && strings.HasPrefix(pm.Path, "cmd/") {
+ // Omit "cmd" from the directory listing on
+ // pkg.go.dev/std, since go list std does not
+ // list them.
+ continue
+ }
sdirs = append(sdirs, &Subdirectory{
URL: constructUnitURL(pm.Path, um.ModulePath, linkVersion(um.Version, um.ModulePath)),
Suffix: internal.Suffix(pm.Path, um.Path),
