tartrazine/extension.go

24 lines
332 B
Go
Raw Normal View History

2016-07-13 17:05:09 +00:00
package slinguist
import (
"path/filepath"
"strings"
2016-07-13 17:05:09 +00:00
)
func GetLanguageByExtension(filename string) (lang string, safe bool) {
ext := strings.ToLower(filepath.Ext(filename))
2016-07-13 17:05:09 +00:00
lang = OtherLanguage
2016-07-18 14:20:12 +00:00
langs, ok := languagesByExtension[ext]
2016-07-13 17:05:09 +00:00
if !ok {
return
}
lang = langs[0]
if len(langs) == 1 {
safe = true
}
return
}