mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
20 lines
315 B
Go
20 lines
315 B
Go
package slinguist
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func GetLanguageByExtension(filename string) (lang string, safe bool) {
|
|
ext := strings.ToLower(filepath.Ext(filename))
|
|
lang = OtherLanguage
|
|
langs, ok := languagesByExtension[ext]
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
lang = langs[0]
|
|
safe = len(langs) == 1
|
|
return
|
|
}
|