From 107f6d1f10b3cccbe34fdc817c3ae383e968ec1d Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Tue, 16 Aug 2022 13:41:48 +0700 Subject: [PATCH] feat: support gnu gplv3 --- license.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/license.go b/license.go index 1b992c6..c53c121 100644 --- a/license.go +++ b/license.go @@ -29,6 +29,9 @@ var templates = map[string]templateInfo{ "[fullname]", }, }, + "GNU GPLv3": { + filename: "gnu_gplv3.txt", + }, } type templateInfo struct { @@ -42,8 +45,16 @@ func generateLicense(name string) (string, error) { } name = strings.ToUpper(name) - templateInfo, ok := templates[name] - if !ok { + isSupportTemplate := false + 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) }