title: How pass numpy array from Python to Golang function
body: <p>I'm trying  create library using with Golang for working in Python. But I have one problem: I can't pass numpy array to go function. Please, help me solve problem.</p>
  
  <p>My code:</p>
  
  <p><strong>main.go:</strong></p>
  
  <pre><code>package main
  
  import "C"
  import "fmt"
  
  type Matrix [][] int
  
  //export Mass
  func Mass(data Matrix) int {
    var sum int=0
    for i, x:= range data {
      for j, _ := range x {
          sum+=data[i][j]
      }
    }
    return sum
  }
  
  func main() {
  }
  </code></pre>
  
  <p><strong>ex.py:</strong></p>
  
  <pre><code>from ctypes import *
  import numpy as np
  
  mysum = cdll.LoadLibrary(r'D:\tests\go\sum.dll')
  
  array_2d_int = np.ctypeslib.ndpointer(dtype=c_int32, ndim=2,
                                        flags='CONTIGUOUS')
  
  def mass(a):
      mysum.Mass.argtypes = [array_2d_int]
      mysum.Mass.restype = c_int32
      return mysum.Mass(a)
  </code></pre>
  
  <p><strong>Compiling cmd-line:</strong></p>
  
  <pre><code>go build -buildmode=c-shared -o sum.dll main.go
  </code></pre>
  
  <p>When I call function from dll-library:</p>
  
  <pre><code>from ex import mass
  import numpy as np
  
  a=np.array([[1,2],[3,4]])
  
  print(mass(a))
  </code></pre>
  
  <p>I have errors:</p>
  
  <pre><code>unexpected fault address 0x1b216000
  fatal error: fault
  [signal 0xc0000005 code=0x0 addr=0x1b216000 pc=0x6ac92c1f]
  
  goroutine 17 [running, locked to thread]:
  ....
  </code></pre>