Merge pull request #46 from look/look/add-language-id

Add GetLanguageID function
This commit is contained in:
Alex
2021-04-24 08:32:32 +02:00
committed by GitHub
7 changed files with 680 additions and 0 deletions

View File

@ -500,6 +500,16 @@ func GetLanguageExtensions(language string) []string {
return data.ExtensionsByLanguage[language]
}
// GetLanguageID returns the ID for the language. IDs are assigned by GitHub.
// The input must be the canonical language name. Aliases are not supported.
//
// NOTE: The zero value (0) is a valid language ID, so this API mimics the Go
// map API. Use the second return value to check if the language was found.
func GetLanguageID(language string) (int, bool) {
id, ok := data.IDByLanguage[language]
return id, ok
}
// Type represent language's type. Either data, programming, markup, prose, or unknown.
type Type int