-2

I am trying to do simple http post request using the following code: Golang code from another SO post

It's sending the http request twice (I tried both to my own web service and also to the Firebase messaging server). Anyone have any idea of what's wrong? Thank you.

Edit Ignore me, figured out it's the AVG anti virus causing the problem. If I do:go run program.go then hit enter just once, AVG interrupts saying it has scan it and then let it run. This results in the http call twice. If I disable antivirus before running, then the http requrest is received only once on the other side. I've switched the antivirus on and off a few times to confirm this is the cause.

Community
  • 1
  • 1
NaN
  • 598
  • 3
  • 15
  • If you are using that *exact* code, then the request will not be sent twice; you must be executing it twice. –  Apr 13 '17 at 13:21
  • 1
    ...Unless the server returned a `Location` header, then the HTTP client will follow the redirect. –  Apr 13 '17 at 13:23

1 Answers1

1

As in my edit, the cause was AVG anti virus. There was nothing in the console log indicating any part of the program was run twice. Not sure why the downvotes, I spend a few hours on this, move from Firebase messaging server to my own webserver to remove external dependency, and even read the source in net/http package.

NaN
  • 598
  • 3
  • 15