Do not return empty lang.

It's better to return any potential candidate than nothing.

Signed-off-by: kuba-- <kuba@sourced.tech>
This commit is contained in:
kuba--
2019-03-14 13:26:00 +01:00
parent e067e45044
commit 5adfee5761
4 changed files with 26 additions and 17 deletions

View File

@ -41,11 +41,12 @@ func GetLanguage(filename string, content []byte) (language string) {
}
func firstLanguage(languages []string) string {
if len(languages) == 0 {
return OtherLanguage
for _, l := range languages {
if l != "" {
return l
}
}
return languages[0]
return OtherLanguage
}
// GetLanguageByModeline returns detected language. If there are more than one possibles languages