[[+content_image]]
S
S
sergey_fs2017-10-24 21:55:08
go
sergey_fs, 2017-10-24 21:55:08

When NULL is returned, is the previous value returned?

Code
https://play.golang.org/p/eFIs1MRxHt
Please tell me I found a bug
When I request data via api
[[email protected] ~]#
[[email protected] ~]# curl -i -u freeswitch:directory -d "method=get_user&name=4" 0.0.0.0:9090/directory
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 24 Oct 2017 18:50:15 GMT
Content-Length: 40
{"username" :"","password":"","state":""}
I get an empty string
after that I will ask where the data is
[[email protected] ~]# curl -i -u freeswitch:directory -d "method =get_user&name=445" 0.0.0.0:9090/directory
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 24 Oct 2017 18:51:13 GMT
Content-Length: 53
{"username":"445","password":"1234","state":"active"}[
then re-request
[[email protected] 216530-2 ~]# curl -i -u freeswitch:directory -d "method=get_user&name=4" 0.0.0.0:9090/directory
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 24 Oct 2017 18 :51:35 GMT
Content-Length: 53
{"username":"445","password":"1234","state":"active"}
and instead of empty values, the previous value is returned
help me understand where the error is thanks in advance

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Alexander Trakhimenok, 2017-10-24
@sergey_fs

You have rec as a global variable. Move its declaration inside the get_user() function and others, if any.

L
Leonid Nikolaev, 2017-10-25
@nikonor

Even without looking at the code: variables must be cleared :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question