func legacyCreateDirectory(dbDir *internal.LegacyDirectory, licmetas []*licenses.Metadata, includeDirPath bool) (_ *Directory, err error) {
	defer derrors.Wrap(&err, "legacyCreateDirectory(%q, %q, %t)", dbDir.Path, dbDir.Version, includeDirPath)

	var packages []*Package
	for _, pkg := range dbDir.Packages {
		if !includeDirPath && pkg.Path == dbDir.Path {
			continue
		}
		newPkg, err := legacyCreatePackage(pkg, &dbDir.ModuleInfo, false)
		if err != nil {
			return nil, err
		}
		if pkg.IsRedistributable {
			newPkg.Synopsis = pkg.Synopsis
		}
		newPkg.PathAfterDirectory = strings.TrimPrefix(strings.TrimPrefix(pkg.Path, dbDir.Path), "/")
		if newPkg.PathAfterDirectory == "" {
			newPkg.PathAfterDirectory = effectiveName(pkg) + " (root)"
		}
		packages = append(packages, newPkg)
	}
	mod := createModule(&dbDir.ModuleInfo, licmetas, false)
	sort.Slice(packages, func(i, j int) bool { return packages[i].Path < packages[j].Path })

	return &Directory{
		Module:   *mod,
		Path:     dbDir.Path,
		Packages: packages,
		URL:      constructDirectoryURL(dbDir.Path, dbDir.ModulePath, linkVersion(dbDir.Version, dbDir.ModulePath)),
	}, nil
}
// legacyCreateDirectory constructs a *LegacyDirectory from the provided dbDir and licmetas.
//
// includeDirPath indicates whether a package is included if its import path is
// the same as dirPath.
// This argument is needed because on the module "Packages" tab, we want to
// display all packages in the mdoule, even if the import path is the same as
// the module path. However, on the package and directory view's
// "Subdirectories" tab, we do not want to include packages whose import paths
// are the same as the dirPath.
legacyCreateDirectory constructs a *LegacyDirectory from the provided dbDir and licmetas.

includeDirPath indicates whether a package is included if its import path is
the same as dirPath.
This argument is needed because on the module "Packages" tab, we want to
display all packages in the mdoule, even if the import path is the same as
the module path. However, on the package and directory view's
"Subdirectories" tab, we do not want to include packages whose import paths
are the same as the dirPath.
// legacyCreateDirectory constructs a * LegacyDirectory from the provided dbDir and licmetas . // // includeDirPath indicates whether a package is included if its import path is // the same as dirPath . // This argument is needed because on the module " Packages " tab we want to // display all packages in the mdoule even if the import path is the same as // the module path . However on the package and directory view ' s // " Subdirectories " tab we do not want to include packages whose import paths // are the same as the dirPath .
func legacyCreateDirectory(dbDir *internal.LegacyDirectory, licmetas []*licenses.Metadata, includeDirPath bool) (_ *Directory, err error) {
	defer derrors.Wrap(&err, "legacyCreateDirectory(%q, %q, %t)", dbDir.Path, dbDir.Version, includeDirPath)
	var packages []*Package
	for _, pkg := range dbDir.Packages {
		if !includeDirPath && pkg.Path == dbDir.Path {
			continue
		}
		newPkg, err := legacyCreatePackage(pkg, &dbDir.ModuleInfo, false)
		if err != nil {
			return nil, err
		}
		if pkg.IsRedistributable {
			newPkg.Synopsis = pkg.Synopsis
		}
		newPkg.PathAfterDirectory = strings.TrimPrefix(strings.TrimPrefix(pkg.Path, dbDir.Path), "/")
		if newPkg.PathAfterDirectory == "" {
			newPkg.PathAfterDirectory = effectiveName(pkg) + " (root)"
		}
		packages = append(packages, newPkg)
	}
	mod := createModule(&dbDir.ModuleInfo, licmetas, false)
	sort.Slice(packages, func(i, j int) bool { return packages[i].Path < packages[j].Path })
	return &Directory{
		Module:   *mod,
		Path:     dbDir.Path,
		Packages: packages,
		URL:      constructDirectoryURL(dbDir.Path, dbDir.ModulePath, linkVersion(dbDir.Version, dbDir.ModulePath)),
	}, nil
}
func legacyCreateDirectory ( dbDir * internal . LegacyDirectory , licmetas [ ] * licenses . Metadata , includeDirPath bool ) ( _ * Directory , err error ) { defer derrors . Wrap ( & err , " " , dbDir . Path , dbDir . Version , includeDirPath ) var packages [ ] * Package for _ , pkg := range dbDir . Packages { if ! includeDirPath && pkg . Path == dbDir . Path { continue } newPkg , err := legacyCreatePackage ( pkg , & dbDir . ModuleInfo , false ) if err != nil { return nil , err } if pkg . IsRedistributable { newPkg . Synopsis = pkg . Synopsis } newPkg . PathAfterDirectory = strings . TrimPrefix ( strings . TrimPrefix ( pkg . Path , dbDir . Path ) , " " ) if newPkg . PathAfterDirectory == " " { newPkg . PathAfterDirectory = effectiveName ( pkg ) + " " } packages = append ( packages , newPkg ) } mod := createModule ( & dbDir . ModuleInfo , licmetas , false ) sort . Slice ( packages , func ( i , j int ) bool { return packages [ i ] . Path < packages [ j ] . Path } ) return & Directory { Module : * mod , Path : dbDir . Path , Packages : packages , URL : constructDirectoryURL ( dbDir . Path , dbDir . ModulePath , linkVersion ( dbDir . Version , dbDir . ModulePath ) ) , } , nil }
legacyCreateDirectory constructs a *LegacyDirectory from the provided dbDir and licmetas.
legacyCreateDirectory constructs a * LegacyDirectory from the provided dbDir and licmetas .