func moduleDirectories(modulePath string,
	pkgs []*internal.LegacyPackage,
	readmes []*internal.Readme,
	d *licenses.Detector) []*internal.DirectoryNew {
	pkgLookup := map[string]*internal.LegacyPackage{}
	for _, pkg := range pkgs {
		pkgLookup[pkg.Path] = pkg
	}
	dirPaths := directoryPaths(modulePath, pkgs)

	readmeLookup := map[string]*internal.Readme{}
	for _, readme := range readmes {
		if path.Dir(readme.Filepath) == "." {
			readmeLookup[modulePath] = readme
		} else if modulePath == stdlib.ModulePath {
			readmeLookup[path.Dir(readme.Filepath)] = readme
		} else {
			readmeLookup[path.Join(modulePath, path.Dir(readme.Filepath))] = readme
		}
	}

	var directories []*internal.DirectoryNew
	for _, dirPath := range dirPaths {
		suffix := strings.TrimPrefix(strings.TrimPrefix(dirPath, modulePath), "/")
		if modulePath == stdlib.ModulePath {
			suffix = dirPath
		}
		isRedist, lics := d.PackageInfo(suffix)
		var meta []*licenses.Metadata
		for _, l := range lics {
			meta = append(meta, l.Metadata)
		}
		dir := &internal.DirectoryNew{
			DirectoryMeta: internal.DirectoryMeta{
				Path:              dirPath,
				V1Path:            internal.V1Path(modulePath, suffix),
				IsRedistributable: isRedist,
				Licenses:          meta,
			},
		}
		if r, ok := readmeLookup[dirPath]; ok {
			dir.Readme = r
		}
		if pkg, ok := pkgLookup[dirPath]; ok {
			dir.Package = &internal.PackageNew{
				Path:    pkg.Path,
				Name:    pkg.Name,
				Imports: pkg.Imports,
				Documentation: &internal.Documentation{
					GOOS:     pkg.GOOS,
					GOARCH:   pkg.GOARCH,
					Synopsis: pkg.Synopsis,
					HTML:     pkg.DocumentationHTML,
				},
			}
		}
		directories = append(directories, dir)
	}
	return directories
}
// moduleDirectories returns all of the directories in a given module, along
// with the contents for those directories.
moduleDirectories returns all of the directories in a given module, along
with the contents for those directories.
// moduleDirectories returns all of the directories in a given module along // with the contents for those directories .
func moduleDirectories(modulePath string,
	pkgs []*internal.LegacyPackage,
	readmes []*internal.Readme,
	d *licenses.Detector) []*internal.DirectoryNew {
	pkgLookup := map[string]*internal.LegacyPackage{}
	for _, pkg := range pkgs {
		pkgLookup[pkg.Path] = pkg
	}
	dirPaths := directoryPaths(modulePath, pkgs)
	readmeLookup := map[string]*internal.Readme{}
	for _, readme := range readmes {
		if path.Dir(readme.Filepath) == "." {
			readmeLookup[modulePath] = readme
		} else if modulePath == stdlib.ModulePath {
			readmeLookup[path.Dir(readme.Filepath)] = readme
		} else {
			readmeLookup[path.Join(modulePath, path.Dir(readme.Filepath))] = readme
		}
	}
	var directories []*internal.DirectoryNew
	for _, dirPath := range dirPaths {
		suffix := strings.TrimPrefix(strings.TrimPrefix(dirPath, modulePath), "/")
		if modulePath == stdlib.ModulePath {
			suffix = dirPath
		}
		isRedist, lics := d.PackageInfo(suffix)
		var meta []*licenses.Metadata
		for _, l := range lics {
			meta = append(meta, l.Metadata)
		}
		dir := &internal.DirectoryNew{
			DirectoryMeta: internal.DirectoryMeta{
				Path:              dirPath,
				V1Path:            internal.V1Path(modulePath, suffix),
				IsRedistributable: isRedist,
				Licenses:          meta,
			},
		}
		if r, ok := readmeLookup[dirPath]; ok {
			dir.Readme = r
		}
		if pkg, ok := pkgLookup[dirPath]; ok {
			dir.Package = &internal.PackageNew{
				Path:    pkg.Path,
				Name:    pkg.Name,
				Imports: pkg.Imports,
				Documentation: &internal.Documentation{
					GOOS:     pkg.GOOS,
					GOARCH:   pkg.GOARCH,
					Synopsis: pkg.Synopsis,
					HTML:     pkg.DocumentationHTML,
				},
			}
		}
		directories = append(directories, dir)
	}
	return directories
}
func moduleDirectories ( modulePath string , pkgs [ ] * internal . LegacyPackage , readmes [ ] * internal . Readme , d * licenses . Detector ) [ ] * internal . DirectoryNew { pkgLookup := map [ string ] * internal . LegacyPackage { } for _ , pkg := range pkgs { pkgLookup [ pkg . Path ] = pkg } dirPaths := directoryPaths ( modulePath , pkgs ) readmeLookup := map [ string ] * internal . Readme { } for _ , readme := range readmes { if path . Dir ( readme . Filepath ) == " " { readmeLookup [ modulePath ] = readme } else if modulePath == stdlib . ModulePath { readmeLookup [ path . Dir ( readme . Filepath ) ] = readme } else { readmeLookup [ path . Join ( modulePath , path . Dir ( readme . Filepath ) ) ] = readme } } var directories [ ] * internal . DirectoryNew for _ , dirPath := range dirPaths { suffix := strings . TrimPrefix ( strings . TrimPrefix ( dirPath , modulePath ) , " " ) if modulePath == stdlib . ModulePath { suffix = dirPath } isRedist , lics := d . PackageInfo ( suffix ) var meta [ ] * licenses . Metadata for _ , l := range lics { meta = append ( meta , l . Metadata ) } dir := & internal . DirectoryNew { DirectoryMeta : internal . DirectoryMeta { Path : dirPath , V1Path : internal . V1Path ( modulePath , suffix ) , IsRedistributable : isRedist , Licenses : meta , } , } if r , ok := readmeLookup [ dirPath ] ; ok { dir . Readme = r } if pkg , ok := pkgLookup [ dirPath ] ; ok { dir . Package = & internal . PackageNew { Path : pkg . Path , Name : pkg . Name , Imports : pkg . Imports , Documentation : & internal . Documentation { GOOS : pkg . GOOS , GOARCH : pkg . GOARCH , Synopsis : pkg . Synopsis , HTML : pkg . DocumentationHTML , } , } } directories = append ( directories , dir ) } return directories }
moduleDirectories returns all of the directories in a given module, along
with the contents for those directories.
moduleDirectories returns all of the directories in a given module along with the contents for those directories .