Hello,
I need some assistance with a little code relative to http.post client that
request a remote json.
jsonData := map[string]string{"firstname": "Nic", "lastname": "Raboy"}
jsonValue, _ := json.Marshal(jsonData)
response, err = http.Post("https://httpbin.org/post", "application/json"
, bytes.NewBuffer(jsonValue))
defer response.Body.Close()
if err != nil {
data = fmt.Sprintf("The HTTP request failed with error %s\n", err)
} else {
rawdata, _ := ioutil.ReadAll(response.Body)
data = string(rawdata)
}
return data
when i try just after to retrieve the return to a string cgo variable
result := C.CString(data)
it returns an exception. From my understanding, it seems to be an
aynchronous error message relative to http. But in this context it should
be synchronous.
Exception 0xc0000005 0x0 0x1e7e1af9000 0x7ffc1f804365
Au caractère Ligne:1 : 1
+ .\callExtension_x64.exe .\test_script.sqf 2> log.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Exception 0xc00...
0x7ffc1f804365:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PC=0x7ffc1f804365
signal arrived during external code execution
main._Cfunc_memmove(0x6b5b4fbdf0
, 0x1e7e1af7a30, 0x27ff, 0x0)
_cgo_gotypes.go:77 +0x55
main.RVExtension.func2(0x6b5b4fbdf0, 0x1e7e1af7a30
, 0x27ff
, 0x1
)
C:/Users/code34/go/src/github.com/code34/armaws_x64/armaws_x64.go:
50 +
0xa0
main.RVExtension(0x6b5b4fbdf0, 0x2800,
0x6b5b4febd0)
C:/Users/code34/go/src/github.com/code34/armaws_x64/armaws_x64.go
:50
+0x11f
main._cgoexpwrap_46df507b520b_RVExtension(0x6b5b4fbdf0, 0x2800, 0x6b5b4febd0
)
_cgo_gotypes.go:122 +0x46
goroutine 38 [select]:
net/http.(*persistConn).writeLoop(
0xc0420a4fc0)
C:/Go/src/net/http/transport.go:1822 +0x152
created by net/http.(*Transport).dialConn
C:/Go/src/net/http/transport.go:1238 +0x986
goroutine 37
[IO wait
]:
internal/poll.runtime_pollWait(0x1e7e1974ea0, 0x72, 0x69521b80)
C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc0421301c8, 0x72, 0x69612100, 0x0, 0x0)
C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2
internal/poll.(*ioSrv).ExecIO(0x69649118, 0xc042130018, 0x69504890, 0x32,
0x1, 0x1)
C:/Go/src/internal/poll/fd_windows.go:223 +0x13a
internal/poll.(*FD).Read(0xc042130000, 0xc04213c400, 0x400, 0x400, 0x0, 0x0,
0x0)
C:/Go/src/internal/poll/fd_windows.go:484 +0x248
net.(*netFD).Read(0xc042130000, 0xc04213c400, 0x400, 0x400, 0x692d6fe0,
0xc04204c710, 0x0)
C:/Go/src/net/fd_windows.go:151 +0x56
net.(*conn).Read(0xc042004010, 0xc04213c400, 0x400, 0x400, 0x0, 0x0, 0x0)
C:/Go/src/net/net.go:176 +0x71
crypto/tls.(*block).readFromUntil(0xc0421340c0, 0x1e7e19b0000, 0xc042004010,
0x5, 0xc042004010, 0x0)
C:/Go/src/crypto/tls/conn.go:493 +0x9d
crypto/tls.(*Conn).readRecord(0xc042006380, 0x69505017, 0xc0420064a0,
0x692d2270)
C:/Go/src/crypto/tls/conn.go:595 +0xe7
crypto/tls.(*Conn).Read(0xc042006380, 0xc042145000, 0x1000, 0x1000, 0x0, 0x0
, 0x0)
C:/Go/src/crypto/tls/conn.go:1156 +0x107
net/http.(*persistConn).Read(0xc0420a4fc0, 0xc042145000, 0x1000, 0x1000,
0xc042113b98, 0x69284995, 0xc042012120)
C:/Go/src/net/http/transport.go:1453 +0x13d
bufio.(*Reader).fill(0xc04205c2a0)
C:/Go/src/bufio/bufio.go:100 +0x125
bufio.(*Reader).Peek(0xc04205c2a0, 0x1, 0x0, 0x0, 0x0, 0xc042012180, 0x0)
C:/Go/src/bufio/bufio.go:132 +0x41
net/http.(*persistConn).readLoop(0xc0420a4fc0)
C:/Go/src/net/http/transport.go:1601 +
0x18c
created by net/http.(*Transport).dialConn
C:/Go/src/net/http/transport.go:1237 +0x961
rax 0xc04203e000
rbx 0xc04203ddc8
rcx 0x6b5b4fd3b0
rdi
0xc04203e000
rsi 0xc042028180
rbp
0xc04203dd78
rsp 0x6b5b4fbad8
r8 0x1f
r9 0x91
r10 0x2
r11 0x6b5b4fbdf0
r12
0xffffffffffffffff
r13 0x3
r14
0x2
r15 0x11
rip 0x7ffc1f804365
rflags 0x10202
cs 0x33
fs 0x53
gs 0x2b
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.