title: Using generated Golang DLL to return string or *C.Char
body: <p>I've been trying to follow <a href="https://github.com/z505/goDLL" rel="nofollow noreferrer">z505/goDLL</a> repo and came across a big problem.
  The method won't work returning for strings not I'm able to read the output variable of the result.</p>
  
  <p>This is the code I'm using so far (Go) (full code <a href="https://play.golang.org/p/Yfg85DCeMLh" rel="nofollow noreferrer">https://play.golang.org/p/Yfg85DCeMLh</a>)</p>
  
  <pre><code>//export PrintHello2
  func PrintHello2(Input *C.char, Output **C.char) int32 {
      fmt.Println(C.GoString(Input))
      *Output = C.CString(fmt.Sprintf("From DLL: Hello, %s!\n", C.GoString(Input)))
      fmt.Println("Message: ", C.GoString(*Output))
      return 1
  }
  
  //export PrintHello3
  func PrintHello3(Input *C.char, Output *int32) int32 {
      fmt.Println(C.GoString(Input))
      *Output = 3
      fmt.Println("Value: ", *Output)
      return 0
  }
  </code></pre>
  
  <p><strong>C# testing code</strong></p>
  
  <pre><code>class Program
  {
      [DllImport("goDLL.dll", CharSet = CharSet.Unicode)]
      public static extern int PrintHello2(byte[] data, ref byte[] output);
  
      [DllImport("goDLL.dll", CharSet = CharSet.Unicode)]
      public static extern int PrintHello3(byte[] data, ref int output);
  
      static void Main(string[] args)
      {
          string res = "demo";
          byte[] output = null;
          Int32 refVal = 0;
  
          Console.WriteLine("PrintHello3 Returns: " + PrintHello3(Encoding.UTF8.GetBytes(res), ref refVal));
          Console.WriteLine("Ref Val changed to: " + refVal + "\n");
          Console.WriteLine("PrintHello2 Returns: " + PrintHello2(Encoding.UTF8.GetBytes(res), ref output));
          Console.WriteLine("Ref Val changed to: " + Encoding.UTF8.GetString(output) + "\n");
      }
  }
  </code></pre>
  
  <p><em>Expected output result:</em></p>
  
  <pre><code>C:\tmp\DLL&gt;ConsoleApp.exe
  demo
  Value:  3
  PrintHello3 Returns: 0
  Ref Val changed to: 3
  
  demo
  Message:  From DLL: Hello, demo!
  PrintHello2 Returns: 1
  Ref Val changed to: From DLL: Hello, demo!
  </code></pre>
  
  <p><em>Current result:</em></p>
  
  <pre><code>C:\tmp\DLL&gt;ConsoleApp.exe
  demo
  Value:  3
  PrintHello3 Returns: 0
  Ref Val changed to: 3
  
  demo
  Message:  From DLL: Hello, demo!
  </code></pre>
  
  <p>No panic visible, no error found. Just incomplete output
  thx</p>