Exemplo n.º 1
0
func (grok *Grok) Compile(str string) error {

	cstr := C.CString(str)
	defer C.free(unsafe.Pointer(cstr))
	ret := C.grok_compile(grok.grok, cstr)
	if ret != C.GROK_OK {
		return GrokError{ret}
	}
	return nil
}
Exemplo n.º 2
0
func (grok *Grok) Compile(pattern string) error {
	p := C.CString(pattern)
	defer C.free(unsafe.Pointer(p))

	ret := C.grok_compile(grok.g, p)
	if ret != GROK_OK {
		return errors.New(fmt.Sprintf("Failed to compile: %s", C.GoString(grok.g.errstr)))
	}

	return nil
}