I think the error is trying to tell you the C reopen function takes a pointer to a function and you are passing it a Go func. Try googling "cgo pass function pointer". That should yield documents like https://eli.thegreenplace.net/2019/passing-callbacks-and-pointers-to-cgo/ which should point you in the right direction. I have to say, trying to do something like this after using Go for just one month is very ambitious. I think you are going to run into lots of problems due to your lack of experience with Go (not Golang).
On Tue, Nov 21, 2023 at 7:28 PM ulis lee <ulis....@gmail.com> wrote: > *Hi, all* > > It's been a month since I started Golang. > But I was in a difficult situation. I need your help. > > *C code* > > int reopen (const char *fn, time_t check_interval_sec, int > (*callback_func) (int num_entry, char **entry), int retry); > > > *Go code* > > func _Open(fileName string, intervalSec int, f func(C.int, **C.char) > C.int) int { > > cFileName := C.CString(fileName) > > defer C.free(unsafe.Pointer(cFileName)) > > > ret := C.reopen(cFileName, C.long(intervalSec), f, 1) > > return int(ret) > > } > > error message > cannot use f (variable of type func(_Ctype_int, **_Ctype_char) _Ctype_int) > as *[0]byte value in argument to (_Cfunc_reopen) > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/644e20e4-0734-4fe7-be0e-0b4d101df1fdn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/644e20e4-0734-4fe7-be0e-0b4d101df1fdn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_LoPj%2BkoMy%3DTrt6vA2Y0GxAp4h4ngTKmwZfkenStD7rg%40mail.gmail.com.