Source File
license.go
Belonging Package
golang.org/x/pkgsite/internal/frontend
package frontend
import (
)
type LicensesDetails struct {
Licenses []License
}
type LicenseMetadata struct {
Type string
Anchor safehtml.Identifier
}
func ( context.Context, internal.DataSource, *internal.UnitMeta) (*LicensesDetails, error) {
, := .GetUnit(, , internal.WithLicenses, internal.BuildContext{})
if != nil {
return nil,
}
return &LicensesDetails{Licenses: transformLicenses(.ModulePath, .Version, .LicenseContents)}, nil
}
func (, string, []*licenses.License) []License {
:= make([]License, len())
var []string
for , := range {
= append(, .FilePath)
}
:= licenseAnchors()
for , := range {
.Contents = bytes.ReplaceAll(.Contents, []byte("\r"), nil)
[] = License{
Anchor: [],
License: ,
Source: fileSource(, , .FilePath),
}
}
return
}
func ( []*licenses.Metadata) []LicenseMetadata {
var []LicenseMetadata
var []string
for , := range {
= append(, .FilePath)
}
:= licenseAnchors()
for , := range {
:= []
for , := range .Types {
= append(, LicenseMetadata{
Type: ,
Anchor: ,
})
}
}
return
}
sort.Strings()
:= make([]safehtml.Identifier, len())
for , := range {
[[]] = safehtml.IdentifierFromConstantPrefix("lic", strconv.Itoa())
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |