mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 22:23:07 -03:00
Update GetLanguageID to return a found boolean per code review
This commit is contained in:
10
common.go
10
common.go
@ -491,11 +491,13 @@ func GetLanguageExtensions(language string) []string {
|
||||
}
|
||||
|
||||
// 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 has no way to
|
||||
// distinguish an invalid language name and a match on the language with ID 0.
|
||||
func GetLanguageID(language string) int {
|
||||
return data.IDByLanguage[language]
|
||||
// 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.
|
||||
|
Reference in New Issue
Block a user