Documentation
¶
Index ¶
- Constants
- Variables
- func GetLanguage(filename string, content []byte) string
- func GetLanguageByAlias(alias string) (lang string)
- func GetLanguageByContent(filename string, content []byte) (lang string, safe bool)
- func GetLanguageByEmacsModeline(content []byte) (lang string)
- func GetLanguageByExtension(filename string) (lang string, safe bool)
- func GetLanguageByFilename(filename string) (lang string, safe bool)
- func GetLanguageByModeline(content []byte) (lang string, safe bool)
- func GetLanguageByShebang(content []byte) (lang string, safe bool)
- func GetLanguageByVimModeline(content []byte) (lang string)
- func GetLanguageExtensions(language string) []string
- func IsAuxiliaryLanguage(lang string) bool
- func IsBinary(data []byte) bool
- func IsConfiguration(path string) bool
- func IsDocumentation(path string) bool
- func IsDotFile(path string) bool
- func IsVendor(path string) bool
- type Type
Constants ¶
const OtherLanguage = "Other"
Variables ¶
var (
ExtensionsByLanguage map[string][]string
)
Functions ¶
func GetLanguage ¶
GetLanguage return the Language for a given filename and file content.
func GetLanguageByAlias ¶
GetLanguageByAlias returns the language related to the given alias or Otherlanguage otherwise.
func GetLanguageByContent ¶
func GetLanguageByEmacsModeline ¶
GetLanguageByEmacsModeline detecs if the content has a emacs modeline and try to get a language basing on alias. If couldn't retrieve a valid language, it returns OtherLanguage.
func GetLanguageByExtension ¶
func GetLanguageByFilename ¶
func GetLanguageByModeline ¶
GetLanguageByModeline returns the language of the given content looking for the modeline, and safe to indicate the sureness of returned language.
func GetLanguageByShebang ¶
GetLanguageByShebang returns the language of the given content looking for the shebang line, and safe to indicate the sureness of returned language.
func GetLanguageByVimModeline ¶
GetLanguageByVimModeline detecs if the content has a vim modeline and try to get a language basing on alias. If couldn't retrieve a valid language, it returns OtherLanguage.
func GetLanguageExtensions ¶
GetLanguageExtensions returns the different extensions being used by the language.
func IsAuxiliaryLanguage ¶
func IsBinary ¶
IsBinary detects if data is a binary value based on: http://git.kernel.org/cgit/git/git.git/tree/xdiff-interface.c?id=HEAD#n198