package web import ( "strings" "github.com/google/licensecheck" ) func firstLicense(files []string) string { for _, want := range []string{ "license", "licence", "license.md", "licence.md", "license.txt", "licence.txt", "copying", "copying.md", "copying.txt", "copyright", "copyright.md", "copyright.txt", } { for _, file := range files { if !strings.Contains(file, "/") && strings.EqualFold(file, want) { return file } } } return "" } func licenseName(data []byte) string { coverage := licensecheck.Scan(data) best := "" bestLength := 0 for _, match := range coverage.Match { if match.ID == "" { continue } if length := match.End - match.Start; length > bestLength { best = match.ID bestLength = length } } return best }