rgbkrk / libvirt-go

[DEPRECATED] Go bindings for libvirt
https://github.com/libvirt/libvirt-go
MIT License
166 stars 50 forks source link

Add method to enable setting ptr on VirConnection #81

Closed donoftime closed 8 years ago

donoftime commented 8 years ago

Since ptr is not exported, we need a function to allow it to be set by another package.

Also, since the type of ptr is derived from C, other packages cannot be cast to that type (C.virConnectPtr becomes libvirt.C.virConnectPtr)

This function will solve both problems by being exported, and then handling the type casting to C.virConnectPtr. This way someone can just send us a pointer to the connection they created themselves, and we can still use it in the library.


The reason I want to do this is because the virConnectOpenAuth function is not implemented in this package. I wanted to just implement that method here, but did not figure out how to handle types declared in C which get namespaced by the package - thereby preventing people from passing in their callback since it would not be of type libvirt.C.virConnectPtr.

So instead I just opened up VirConnection to allow me to implement the virConnectOpenAuth method in my other package, and then just set the resulting pointer in a libvirt.VirConnection.

rgbkrk commented 8 years ago

Adding you as a collaborator @donoftime, thanks for the contribution.