func createPackageNew(vdir *internal.VersionedDirectory, latestRequested bool) (_ *Package, err error) {
	defer derrors.Wrap(&err, "createPackageNew(%v, %t)", vdir, latestRequested)

	if vdir == nil || vdir.Package == nil {
		return nil, fmt.Errorf("package info must not be nil")
	}

	var modLicenses []*licenses.Metadata
	for _, lm := range vdir.Licenses {
		if path.Dir(lm.FilePath) == "." {
			modLicenses = append(modLicenses, lm)
		}
	}

	m := createModule(&vdir.ModuleInfo, modLicenses, latestRequested)
	urlVersion := m.LinkVersion
	if latestRequested {
		urlVersion = internal.LatestVersion
	}
	return &Package{
		Path:              vdir.Path,
		Synopsis:          vdir.Package.Documentation.Synopsis,
		IsRedistributable: vdir.DirectoryNew.IsRedistributable,
		Licenses:          transformLicenseMetadata(vdir.Licenses),
		Module:            *m,
		URL:               constructPackageURL(vdir.Path, vdir.ModulePath, urlVersion),
		LatestURL:         constructPackageURL(vdir.Path, vdir.ModulePath, middleware.LatestVersionPlaceholder),
	}, nil
}
// createPackageNew returns a *Package based on the fields of the specified
// internal package and version info.
//
// latestRequested indicates whether the user requested the latest
// version of the package. If so, the returned Package.URL will have the
// structure /<path> instead of /<path>@<version>.
createPackageNew returns a *Package based on the fields of the specified
internal package and version info.

latestRequested indicates whether the user requested the latest
version of the package. If so, the returned Package.URL will have the
structure / instead of /@.
// createPackageNew returns a * Package based on the fields of the specified // internal package and version info . // // latestRequested indicates whether the user requested the latest // version of the package . If so the returned Package . URL will have the // structure / <path > instead of / <path > @<version > .
func createPackageNew(vdir *internal.VersionedDirectory, latestRequested bool) (_ *Package, err error) {
	defer derrors.Wrap(&err, "createPackageNew(%v, %t)", vdir, latestRequested)
	if vdir == nil || vdir.Package == nil {
		return nil, fmt.Errorf("package info must not be nil")
	}
	var modLicenses []*licenses.Metadata
	for _, lm := range vdir.Licenses {
		if path.Dir(lm.FilePath) == "." {
			modLicenses = append(modLicenses, lm)
		}
	}
	m := createModule(&vdir.ModuleInfo, modLicenses, latestRequested)
	urlVersion := m.LinkVersion
	if latestRequested {
		urlVersion = internal.LatestVersion
	}
	return &Package{
		Path:              vdir.Path,
		Synopsis:          vdir.Package.Documentation.Synopsis,
		IsRedistributable: vdir.DirectoryNew.IsRedistributable,
		Licenses:          transformLicenseMetadata(vdir.Licenses),
		Module:            *m,
		URL:               constructPackageURL(vdir.Path, vdir.ModulePath, urlVersion),
		LatestURL:         constructPackageURL(vdir.Path, vdir.ModulePath, middleware.LatestVersionPlaceholder),
	}, nil
}
func createPackageNew ( vdir * internal . VersionedDirectory , latestRequested bool ) ( _ * Package , err error ) { defer derrors . Wrap ( & err , " " , vdir , latestRequested ) if vdir == nil || vdir . Package == nil { return nil , fmt . Errorf ( " " ) } var modLicenses [ ] * licenses . Metadata for _ , lm := range vdir . Licenses { if path . Dir ( lm . FilePath ) == " " { modLicenses = append ( modLicenses , lm ) } } m := createModule ( & vdir . ModuleInfo , modLicenses , latestRequested ) urlVersion := m . LinkVersion if latestRequested { urlVersion = internal . LatestVersion } return & Package { Path : vdir . Path , Synopsis : vdir . Package . Documentation . Synopsis , IsRedistributable : vdir . DirectoryNew . IsRedistributable , Licenses : transformLicenseMetadata ( vdir . Licenses ) , Module : * m , URL : constructPackageURL ( vdir . Path , vdir . ModulePath , urlVersion ) , LatestURL : constructPackageURL ( vdir . Path , vdir . ModulePath , middleware . LatestVersionPlaceholder ) , } , nil }
createPackageNew returns a *Package based on the fields of the specified
internal package and version info.
createPackageNew returns a * Package based on the fields of the specified internal package and version info .