title: Golang (cgo) - Arbitrary void* interface
body: <p>I am wrapping a C library that has a struct with a void* data field that can be used to arbitrarily hold data.  What would be the best way (if it's even possible) to wrap this in idiomatic Go?</p>
  
  <p>The struct is quite simply:</p>
  
  <pre><code>typedef struct _Foo {
      void * data;
  } Foo;
  </code></pre>
  
  <p>I was hoping to do something like:</p>
  
  <pre><code>type Foo C.Foo
  
  func (f *Foo) SetData(data interface{}) {
      f.data = unsafe.Pointer(&amp;data)
  }
  
  func (f *Foo) Data() interface{} {
      return (interface{})(unsafe.Pointer(f.data))
  }
  </code></pre>
  
  <p>This doesn't work, and is clearly the wrong approach anyways.</p>
  
  <p>I have successfully set a void* data with a length field using a []byte source, but this length-less interface eludes me.</p>