feat: support gnu gplv3

main
sudo pacman -Syu 2022-08-16 13:41:48 +07:00
parent f2e0f3c7e8
commit 107f6d1f10
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 13 additions and 2 deletions

View File

@ -29,6 +29,9 @@ var templates = map[string]templateInfo{
"[fullname]", "[fullname]",
}, },
}, },
"GNU GPLv3": {
filename: "gnu_gplv3.txt",
},
} }
type templateInfo struct { type templateInfo struct {
@ -42,8 +45,16 @@ func generateLicense(name string) (string, error) {
} }
name = strings.ToUpper(name) name = strings.ToUpper(name)
templateInfo, ok := templates[name] isSupportTemplate := false
if !ok { var templateInfo templateInfo
for templateName := range templates {
if strings.EqualFold(templateName, name) {
isSupportTemplate = true
templateInfo = templates[templateName]
}
}
if !isSupportTemplate {
return "", fmt.Errorf("not support license %s: %w", name, ErrInvalidLicense) return "", fmt.Errorf("not support license %s: %w", name, ErrInvalidLicense)
} }