[ad_1]
Disclaimer: this is not a direct answer to your question but rather an attempt to direct you to a proper way of solving your problem.
- Try to avoid a singleton pattern for you
MyApp. In addition,Newis misleading, it doesn’t actually create a new object every time. Instead you could be creating a new instance every time, while preserving the http client connection. - Don’t use constructions like this:
AppCon == (MyApp{}), one day you will shoot in your leg doing this. Use instead a pointer and compare it tonil. - Avoid race conditions. In your code you start a goroutine and immediately proceed to the new iteration of the
forloop. Considering you re-use the wholeMyAppinstance, you essentially introduce a race condition. - Using cookies, you make your connection kinda stateful, but your task seems to require stateless connections. There might be something wrong in such an approach.
[ad_2]
solved Go http client setup for multiple endpoints?