github.com/rohankumardubey/go-enry@v1.7.3/shared/enry.go (about) 1 // +build darwin,cgo linux,cgo 2 // +build amd64 3 4 package main 5 6 import "C" 7 import "gopkg.in/src-d/enry.v1" 8 9 //export GetLanguage 10 func GetLanguage(filename string, content []byte) string { 11 return enry.GetLanguage(filename, content) 12 } 13 14 //export GetLanguageByContent 15 func GetLanguageByContent(filename string, content []byte) (language string, safe bool) { 16 return enry.GetLanguageByContent(filename, content) 17 } 18 19 //export GetLanguageByEmacsModeline 20 func GetLanguageByEmacsModeline(content []byte) (language string, safe bool) { 21 return enry.GetLanguageByModeline(content) 22 } 23 24 //export GetLanguageByExtension 25 func GetLanguageByExtension(filename string) (language string, safe bool) { 26 return enry.GetLanguageByExtension(filename) 27 } 28 29 //export GetLanguageByFilename 30 func GetLanguageByFilename(filename string) (language string, safe bool) { 31 return enry.GetLanguageByFilename(filename) 32 } 33 34 //export GetLanguageByModeline 35 func GetLanguageByModeline(content []byte) (language string, safe bool) { 36 return enry.GetLanguageByModeline(content) 37 } 38 39 //export GetLanguageByShebang 40 func GetLanguageByShebang(content []byte) (language string, safe bool) { 41 return enry.GetLanguageByShebang(content) 42 } 43 44 //export GetLanguageByVimModeline 45 func GetLanguageByVimModeline(content []byte) (language string, safe bool) { 46 return enry.GetLanguageByVimModeline(content) 47 } 48 49 //export GetLanguageExtensions 50 func GetLanguageExtensions(language string, result *[]*C.char) { 51 strSliceCopy(result, enry.GetLanguageExtensions(language)) 52 } 53 54 //export GetLanguages 55 func GetLanguages(filename string, content []byte, result *[]*C.char) { 56 strSliceCopy(result, enry.GetLanguages(filename, content)) 57 } 58 59 //export GetLanguagesByContent 60 func GetLanguagesByContent(filename string, content []byte, candidates []string, result *[]*C.char) { 61 strSliceCopy(result, enry.GetLanguagesByContent(filename, content, candidates)) 62 } 63 64 //export GetLanguagesByEmacsModeline 65 func GetLanguagesByEmacsModeline(filename string, content []byte, candidates []string, result *[]*C.char) { 66 strSliceCopy(result, enry.GetLanguagesByEmacsModeline(filename, content, candidates)) 67 } 68 69 //export GetLanguagesByExtension 70 func GetLanguagesByExtension(filename string, content []byte, candidates []string, result *[]*C.char) { 71 strSliceCopy(result, enry.GetLanguagesByExtension(filename, content, candidates)) 72 } 73 74 //export GetLanguagesByFilename 75 func GetLanguagesByFilename(filename string, content []byte, candidates []string, result *[]*C.char) { 76 strSliceCopy(result, enry.GetLanguagesByFilename(filename, content, candidates)) 77 } 78 79 //export GetLanguagesByModeline 80 func GetLanguagesByModeline(filename string, content []byte, candidates []string, result *[]*C.char) { 81 strSliceCopy(result, enry.GetLanguagesByModeline(filename, content, candidates)) 82 } 83 84 //export GetLanguagesByShebang 85 func GetLanguagesByShebang(filename string, content []byte, candidates []string, result *[]*C.char) { 86 strSliceCopy(result, enry.GetLanguagesByShebang(filename, content, candidates)) 87 } 88 89 //export GetLanguagesByVimModeline 90 func GetLanguagesByVimModeline(filename string, content []byte, candidates []string, result *[]*C.char) { 91 strSliceCopy(result, enry.GetLanguagesByVimModeline(filename, content, candidates)) 92 } 93 94 //export GetMimeType 95 func GetMimeType(path string, language string) string { 96 return enry.GetMIMEType(path, language) 97 } 98 99 //export IsBinary 100 func IsBinary(data []byte) bool { 101 return enry.IsBinary(data) 102 } 103 104 //export IsConfiguration 105 func IsConfiguration(path string) bool { 106 return enry.IsConfiguration(path) 107 } 108 109 //export IsDocumentation 110 func IsDocumentation(path string) bool { 111 return enry.IsDocumentation(path) 112 } 113 114 //export IsDotFile 115 func IsDotFile(path string) bool { 116 return enry.IsDotFile(path) 117 } 118 119 //export IsImage 120 func IsImage(path string) bool { 121 return enry.IsImage(path) 122 } 123 124 //export IsVendor 125 func IsVendor(path string) bool { 126 return enry.IsVendor(path) 127 } 128 129 func strSliceCopy(result *[]*C.char, slice []string) { 130 for _, str := range slice { 131 *result = append(*result, C.CString(str)) 132 } 133 } 134 135 func main() {}