Re: [go-nuts] CGO error : cannot use f ( type func(_Ctype_int, **_Ctype_char) _Ctype_int) as *[0]byte value in argument

2023-11-21 Thread Kurtis Rader
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

[go-nuts] Re: CGO error : cannot use f ( type func(_Ctype_int, **_Ctype_char) _Ctype_int) as *[0]byte value in argument

2023-11-21 Thread Tzu-Yu Lee
Hi, You cannot pass f, which is a Go function, in a CGo call directly because of the pointer passing rules. You need to create some wrappers, and I have found this article (https://eli.thegreenplace.net/2019/passing-callbacks-and-pointers-to-cgo) very helpful. That being said, I have a

[go-nuts] CGO error : cannot use f ( type func(_Ctype_int, **_Ctype_char) _Ctype_int) as *[0]byte value in argument

2023-11-21 Thread ulis lee
*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,

[go-nuts] CGo error : Cannot use f (type func func(_Ctype_int, **_Ctype_char) _Ctype_int) as *[0]byte value in argument

2023-11-21 Thread ulis lee
Hi all, *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

Re: [go-nuts] Re: Measuring the total time of serving a request

2023-11-21 Thread Ulrich Kunitz
You are right Flush needs to write the header first, so the additional header lines cannot be added by the server after Flush. The automatic Content-Type might also not be written. A local proxy in front of your server might be a simpler approach to measure full performance. If the actual

[go-nuts] Re: Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread 'Mark' via golang-nuts
My reply was to Salih but somehow my reply ended up appearing first. According to the purego docs you don't need a compiler, essentially it provides a means of opening a dll/so and registering and calling functions within the dll/so. On Tuesday, November 21, 2023 at 12:58:20 PM UTC Tamás

Re: [go-nuts] Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread 'Salih Muhammed' via golang-nuts
I know that there's purego https://github.com/ebitengine/purego but not totally sure about it can preform without a compiler. -- Regards, Salih -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

[go-nuts] Re: Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread Tamás Gulácsi
Which is what? Please share with the golang-nuts list if you've found a solution! Mark a következőt írta (2023. november 21., kedd, 11:54:11 UTC+1): > Thank you, that looks just like what I want. > > On Tuesday, November 21, 2023 at 10:21:14 AM UTC Mark wrote: > >> I would like to be able to

Re: [go-nuts] Re: Measuring the total time of serving a request

2023-11-21 Thread Mitar
Hi! On Mon, Nov 20, 2023 at 10:51 PM Uli Kunitz wrote: > You could convert the original ResponseWriter to a ResponseController and > call Flush in your middleware before you measure the duration. Alternatively > you can try to convert ResponseWriter to a http.Flusher and call Flush if the >

[go-nuts] Re: Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread 'Mark' via golang-nuts
Thank you, that looks just like what I want. On Tuesday, November 21, 2023 at 10:21:14 AM UTC Mark wrote: > I would like to be able to access a dynamic C library (and ideally C++), > i.e., `.so` or `.dll` _without_ using cgo, i.e., without needing a compiler > on the target platform. > Python

[go-nuts] Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread 'Mark' via golang-nuts
I would like to be able to access a dynamic C library (and ideally C++), i.e., `.so` or `.dll` _without_ using cgo, i.e., without needing a compiler on the target platform. Python provides a `ctypes` module with this facility. Is there an equivalent for Go? -- You received this message