3 // DetectFiletype will use the list of syntax definitions provided and the filename and first line of the file
4 // to determine the filetype of the file
5 // It will return the corresponding syntax definition for the filetype
6 func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
7 for _, d := range defs {
8 if d.ftdetect[0].MatchString(filename) {
11 if len(d.ftdetect) > 1 {
12 if d.ftdetect[1].MatchString(string(firstLine)) {
19 emptyDef.FileType = "Unknown"
20 emptyDef.rules = new(rules)