软件许可证名称表


一、背景

  • 许可证名称非常多,需要建立一个映射关系,将同类型的许可证名称统一映射为简称
  • 在后续使用的时候,统一使用简称

    二、方案

  • 建立一个许可证映射关系表
  • 引擎分析时对许可证名称根据映射关系进行映射,统一改为简称
  • 组件库将组件许可证统一为许可证简称

三、代码实现

import (
	_ "embed"
    "logs"
	"gopkg.in/yaml.v3"
	"strings"
)

//go:embed license.yaml
var licAlias []byte

var licAliasMap = make(map[string]string)

// 初始化
func init() {
	var licConfigMap map[string][]string
	err := yaml.Unmarshal(licAlias, &licConfigMap)
	if err != nil {
		logs.Error(err)
		return
	}
	for key, value := range licConfigMap {
		for _, name := range value {
			name = strings.ReplaceAll(strings.ToLower(name), " ", "")
			licAliasMap[name] = key
		}
	}
}

## 使用
func main(){
    licenseName := "MIT License"
    licTmp := strings.ReplaceAll(strings.ToLower(licenseName), " ", "")
    licName, ok := licAliasMap[licTmp]
    if ok {
        fmt.Println(licName)
    }
}

四、映射表

MIT:
  - 'MIT License'
  - 'Expat License'
  - 'MIT'
  - 'MIT/X11 License'
  - 'X License'
  - 'X11 License'
  - 'MIT Expat License'
  - 'The MIT License'

GPL-3.0:
  - 'GNU General Public License v3.0'
  - 'GPL v3'
  - 'GPLv3'
  - 'GNU GPLv3'
  - 'GNU General Public License, Version 3.0'
  - 'GNU General Public License version 3'
  - '>GNU General Public License (GPL), Version 3.0'

BSD-3-Clause:
  - 'BSD 3-Clause License'
  - 'Modified BSD License'
  - 'A modified BSD License (BSD)'
  - 'New BSD License'
  - 'BSD New license'
  - 'BSD 3-Clause "New"'
  - 'The New BSD License'
  - 'The (New) BSD License'
  - 'BSD New'
  - '"Revised" License'
  - 'BSD Revised License'
  - 'Revised BSD License'
  - 'BSD 3-Clause "New" or "Revised" License'
  - 'BSD-3'
  - 'BSD-3-Clause'
  - '3-Clause BSD License'

LGPL-2.1:
  - 'LGPL 2.1'
  - 'LGPL v2.1'
  - 'GNU LGPLv2.1'
  - 'Lesser GPL v2.1'
  - 'GNU Lesser GPL 2.1'
  - 'GNU Lesser General Public License v2.1'
  - 'GNU Lesser General Public License version 2.1'
  - 'GNU Lesser General Public License, version 2.1'

MPL-2.0:
  - 'Mozilla Public License 2.0'
  - 'MPL v2.0'
  - 'Mozilla Public License, Version 2.0'
  - 'Mozilla License 2.0'

AGPL-3.0:
  - 'AGPLv3'
  - 'GNU AGPLv3'
  - 'Affero GPL3'
  - 'Affero GPL v3.0'
  - 'GNU Affero GPL 3.0'
  - 'GNU Affero General Public License v3.0'
  - 'GNU Affero General Public License version 3'

CC-BY-4.0:
  - 'Creative Commons Attribution 4.0 International'
  - 'Creative Commons Attribution 4.0 International (CC BY 4.0)'
  - 'Creative Commons Attribution 4.0'
  - 'CC BY 4.0'
  - 'Creative Commons Attribution License 4.0'
  - 'Creative Commons Attribution v4.0'
  - 'CC Attribution 4.0'
  - 'CC-BY v4.0'

EPL-2.0:
  - 'Eclipse Public License - v 2.0'
  - 'Eclipse Public License 2.0'
  - 'Eclipse Public License v. 2.0'
  - 'EPL v2.0'
  - 'EPL 2.0'
  - 'Eclipse Public License, Version 2.0'
  - 'Eclipse License 2.0'
  - 'Eclipse License v.2.0'

CDDL-1.0:
  - 'Common Development and Distribution License 1.0'
  - 'CDDL v1.0'
  - 'Common Development and Distribution License, Version 1.0'
  - 'Sun CDDL v1.0'

Unlicense:
  - 'The Unlicense'
  - 'Unlicensed'
  - 'Public Domain'
  - 'Unlicense'
  - 'Unlicense.org'
  - 'Unlicense License'

GPL-2.0:
  - 'GNU General Public License v2.0'
  - 'GPL v2'
  - 'GNU GPLv2'
  - 'GPL2 w/ CPE'
  - 'GNU General Public License, version 2'
  - 'GNU General Public License, Version 2.0'
  - 'GNU General Public License version 2'
  - 'GNU General Public License, version 2 (GPL2)'
  - 'GNU General Public License, version 2, with the Classpath Exception'
  - 'GNU General Public License (GPL), version 2, with the Classpath exception'
  - 'GNU General Public License, version 2 (GPL2), with the classpath exception'

LGPL-3.0:
  - 'LGPLv3.0'
  - 'GNU LGPLv3'
  - 'Lesser GPL v3.0'
  - 'GNU Lesser GPL 3.0'
  - 'GNU Lesser GPL, Version 3'
  - 'GNU Lesser Public License version 3.0'
  - 'GNU Lesser General Public License v3.0'
  - 'GNU Lesser General Public License version 3'
  - 'GNU Lesser General Public Licence, Version 3'
  - 'GNU General Lesser Public License (LGPL) version 3.00'

AGPL-1.0:
  - 'Affero General Public License v1.0'
  - 'AGPL v1.0'
  - 'AGPLv1.0'
  - 'Affero GPL v1.0'
  - 'AGPL-1.0'
  - 'Affero General Public License version 1'

Artistic-2.0:
  - 'Artistic License 2.0'
  - 'Artistic v2.0'
  - 'The Artistic License 2.0'
  - 'Artistic License, Version 2.0'

CC0-1.0:
  - 'Creative Commons Zero v1.0'
  - 'CC0 v1.0'
  - 'CC0 1.0 Universal'
  - 'Creative Commons Zero v1.0 Universal'
  - 'Creative Commons Zero 1.0 Universal'
  - 'CC0 Public Domain Dedication'

Apache-1.1:
  - 'Apache License 1.1'
  - 'Apache Software License 1.1'
  - 'Apache 1.1 License'
  - 'Apache License Version 1.1'
  - 'Apache 1.1'
  - 'ASL 1.1'
  - 'Apache License, Version 1.1'

Apache-2.0:
  - 'ALv2'
  - 'ASL2'
  - 'ASLv2'
  - 'ASL 2.0'
  - 'Apache 2.0'
  - 'Apache License 2.0'
  - 'The Apache License 2.0'
  - 'Apache License, version 2.0'
  - 'The Apache Software License, Version 2.0'
  - 'Apache License, Version 2.0, January 2004'

BSD-2-Clause:
  - 'BSD 2-Clause'
  - 'BSD-2-Clause'
  - 'BSD 2 clause'
  - 'FreeBSD License'
  - 'BSD License 2.0'
  - 'The Simplified BSD'
  - '2-Clause BSD License'
  - 'BSD 2-Clause License'
  - 'Simplified BSD License'
  - 'BSD 2-Clause "Simplified" License'

ISC:
  - 'ISC License'
  - 'Internet Systems Consortium License'
  - 'Internet Systems Consortium'

EPL-1.0:
  - 'Eclipse Public License 1.0'
  - 'EPL v1.0'
  - 'EPL-1.0'
  - 'Eclipse Public License, Version 1.0'
  - 'Eclipse License 1.0'

CC-BY-SA-4.0:
  - 'Creative Commons Attribution Share Alike 4.0 International'
  - 'Creative Commons Attribution-ShareAlike 4.0'
  - 'CC BY-SA 4.0'
  - 'CC-BY-SA-4.0'
  - 'Creative Commons Attribution-ShareAlike License 4.0'
  - 'Creative Commons Attribution-ShareAlike v4.0'
  - 'CC Attribution-ShareAlike 4.0'
  - 'CC-BY-SA v4.0'

Zlib:
  - 'zlib License'
  - 'The zlib/libpng License'
  - 'zlib/libpng License'

WTFPL:
  - 'Do What The F*ck You Want To Public License'
  - 'WTFPL v2'
  - 'WTFPL Version 2'

GPL-1.0:
  - 'GNU General Public License v1.0'
  - 'GPL v1'
  - 'GPLv1'
  - 'GNU GPLv1'
  - 'GNU General Public License, Version 1.0'
  - 'GNU General Public License version 1'

LGPL-2.0:
  - 'LGPL v2.0'
  - 'LGPLv2.0'
  - 'GNU LGPLv2.0'
  - 'GNU Lesser GPL 2.0'
  - 'Lesser GPL v2.0'
  - 'GNU Lesser General Public License v2.0'
  - 'GNU Lesser General Public License version 2'
  - 'GNU Lesser General Public License Version 2.0'

MPL-1.1:
  - 'Mozilla Public License 1.1'
  - 'MPL v1.1'
  - 'MPL 1.1'
  - 'Mozilla Public License, Version 1.1'
  - 'Mozilla License 1.1'

CC-BY-SA-3.0:
  - 'Creative Commons Attribution Share Alike 3.0 Unported'
  - 'Creative Commons Attribution-ShareAlike 3.0'
  - 'Creative Commons Attribution-ShareAlike License 3.0'
  - 'CC Attribution-ShareAlike 3.0'
  - 'CC BY-SA 3.0'
  - 'CC-BY-SA v3.0'

CC-BY-NC-4.0:
  - 'Creative Commons Attribution Non Commercial 4.0 International'
  - 'Creative Commons Attribution-NonCommercial License 4.0'
  - 'Creative Commons Attribution-NonCommercial 4.0'
  - 'Creative Commons Attribution-NonCommercial v4.0'
  - 'CC Attribution-NonCommercial 4.0'
  - 'CC BY-NC 4.0'
  - 'CC-BY-NC v4.0'

CC-BY-ND-4.0:
  - 'Creative Commons Attribution No Derivatives 4.0 International'
  - 'Creative Commons Attribution-NoDerivatives License 4.0'
  - 'Creative Commons Attribution-NoDerivatives 4.0'
  - 'Creative Commons Attribution-NoDerivatives v4.0'
  - 'CC Attribution-NoDerivatives 4.0'
  - 'CC BY-ND 4.0'
  - 'CC-BY-ND v4.0'

CC-BY-NC-SA-4.0:
  - 'Creative Commons Attribution-NonCommercial-ShareAlike License 4.0'
  - 'Creative Commons Attribution-NonCommercial-ShareAlike 4.0'
  - 'Creative Commons Attribution-NonCommercial-ShareAlike v4.0'
  - 'CC Attribution-NonCommercial-ShareAlike 4.0'
  - 'CC BY-NC-SA 4.0'
  - 'CC-BY-NC-SA v4.0'

CC-BY-NC-ND-4.0:
  - 'Creative Commons Attribution-NonCommercial-NoDerivatives 4.0'
  - 'Creative Commons Attribution-NonCommercial-NoDerivatives License 4.0'
  - 'Creative Commons Attribution-NonCommercial-NoDerivatives v4.0'
  - 'CC Attribution-NonCommercial-NoDerivatives 4.0'
  - 'CC BY-NC-ND 4.0'
  - 'CC-BY-NC-ND v4.0'

OFL-1.1:
  - 'SIL Open Font License, Version 1.1'
  - 'SIL Open Font License 1.1'
  - 'SIL OFL v1.1'
  - 'SIL OFL 1.1'
  - 'OFL v1.1'

ZPL-2.1:
  - 'Zope Public License, Version 2.1'
  - 'Zope Public License 2.1'
  - 'Zope License 2.1'
  - 'ZPL v2.1'

ECL-2.0:
  - 'Educational Community License, Version 2.0'
  - 'Educational Community License v2.0'
  - 'Educational Community License 2.0'
  - 'ECL v2.0'

BSD-4-Clause:
  - 'BSD 4-Clause License'
  - 'original "BSD License"'
  - 'Original BSD License'
  - '4-Clause BSD License'
  - '4-clause license'
  - 'BSD License 4.0'
  - 'BSD-4-Clause'

MS-PL:
  - 'Microsoft Public License'
  - 'Microsoft Public License (Ms-PL)'
  - 'Microsoft Permissive License'

MS-RL:
  - 'Microsoft Reciprocal License'
  - 'Microsoft Reciprocal License (Ms-RL)'

IPL-1.0:
  - 'IBM Public License v1.0'
  - 'IBM Public License Version 1.0'

CPL-1.0:
  - 'Common Public License 1.0'
  - 'Common Public License version 1.0'

Author: stream
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source stream !
  TOC