// Detect returns the language code for detected language // in the given text. func Detect(text string) string { cs := C.CString(text) res := C.DetectLang(cs, -1) C.free(unsafe.Pointer(cs)) var lang string if res != nil { lang = C.GoString(res) } return lang }
func (f *Cld2Filter) detectLanguage(input []byte) ([]byte, error) { cstr := C.CString(string(input)) res := C.DetectLang(cstr) return C.GoBytes(unsafe.Pointer(res), C.int(C.strlen(res))), nil }