title: Go: passing argv to C function
body: <p>Since Go 1.6 this code:</p>
  
  <pre><code>argc := len(*argv)
  c_argc := C.int(argc)
  
  c_argv := make([]*C.char, argc)
  for index, value := range *argv {
      c_argv[index] = C.CString(value)
      defer C.free(unsafe.Pointer(c_argv[index]))
  }
  
  err := C.MPI_Init(&amp;c_argc, (***C.char)(unsafe.Pointer(&amp;c_argv)))
  </code></pre>
  
  <p>Doesn not work anymore and fails with <code>runtime error: cgo argument has Go pointer to Go pointer</code>. I have read about allocing the array in C with malloc() and then copying everything but this is very difficult to do (because the argv elements have different lengths and also very unperformant</p>