title: Go type conversions and unexported CGo types
body: <p>Suppose there is CGo package with a struct defined like this:</p>
  
  <pre><code>package test
  ...
  type Test struct {
      Field *C.C_Test
  }
  ...
  </code></pre>
  
  <p>Now suppose that from somewhere else I get <code>unsafe.Pointer</code> which I know points to <code>C_Test</code> C structure.</p>
  
  <p>Do I understand correctly that there is <em>completely</em> no way to create new <code>test.Test</code> instance from the <code>unsafe.Pointer</code> value while being in a package <em>other</em> than <code>test</code>?</p>
  
  <p>Attempting to use something like <code>&amp;test.Test{ptr}</code>, where <code>ptr</code> is <code>unsafe.Pointer</code> value, fails for obvious reasons with message <code>cannot use ptr (type unsafe.Pointer) as type *test._Ctype_C_Test</code> in field value, and type conversion to <code>*test._Ctype_C_Test</code> does not work as well because this type is not exported.<br>
  And I think that making my other module to use CGo and redefining the same C structure in it will not work either since that package will have something like <code>client._Ctype_C_Test</code> but <code>test.Test</code> requires <code>test._Ctype_C_Test</code>, and they are different from the point of view of the typechecker.</p>
  
  <p><strong>Some background:</strong> I need a way to create such structure when I use <code>GtkBuilder</code> with <a href="https://github.com/mattn/go-gtk" rel="nofollow"><code>go-gtk</code></a> library.<br>
  Its <code>GtkBuilder.GetObject(name)</code> method returns <code>*GObject</code> pointer which in turn contains <code>unsafe.Pointer</code> field which I need to turn somehow into, say, <code>gtk.GtkEntry</code> struct. <code>gtk.GtkEntry</code> itself contains implicit field of type <code>gtk.GtkWidget</code> which has explicit field of type <code>*C.GtkWidget</code>, so I need to convert <code>unsafe.Pointer</code> to <code>*C.GtkWidget</code>, but I cannot, as I have described in the simple example above.</p>
  
  <p><strong>Update:</strong> here is the code I'm trying to force to work: <a href="https://gist.github.com/4141343" rel="nofollow">https://gist.github.com/4141343</a></p>