My Go code is:
func Test(websites []string) {
fmt.Print("test")
}
I use gopy build
to produce the httpget.so
file
I then try to load ans use this module, httpget.so
, in my Python code:
import httpget
print dir(httpget)
httpget.Test(["aaaa"])
But calling that function results in a panic on the Go side:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x103998688]
goroutine 17 [running, locked to thread]:
main.cgo_func_httpget_Test(0x1)
/private/var/folders/yg/tx1wr1c5233fd299lpqnvjy40000gn/T/gopy-066392802/httpget.go:173 +0x18
goroutine 18 [syscall, locked to thread]:
runtime.goexit()
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1
How should I fix this problem?
ok,i find the way!! 23333
golang
var (
WebSites = [1]string{"aaa"}
)
in the python
import httpget
s = httpget.GetWebSites()
s[0] = "http://www.baidu.com"
httpget.Test(s)