Skip to content

Setting callback to method of a type #9

@arun1587

Description

@arun1587

Hi all,
Is it possible to have a callback method which is of any specific type?
example:

type nfqCallback struct {
	pool *redis.Pool
} 
func(n nfqCallback) real_callback(payload *nfqueue.Payload) int {
   // access the pool here
}

// some where in main
w := nfqCallback{pool: p} 
queue.SetCallback(w.real_callback)

I tried to run the code but it panic'ed with the following trace.

panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 10 [running]:
panic(0x995e40, 0xc42120ecc0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue._cgoCheckPointer0(0xc4212122a0, 0x0, 0x0, 0x0, 0x0)
        ??:0 +0x59
bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue.(*Queue).CreateQueue(0xc4212122a0, 0x0, 0x0, 0x0)
        /home/arun/work/src/bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue/nfqueue.go:165 +0x155

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions