[Solved] How to send JSON body in GET request golang?


Sending a body with a GET request is not supported by HTTP. See this Q&A for full details. But if you really want to do this, even though you know it’s wrong, you can do it this way:

iKnowThisBodyShouldBeIgnored := strings.NewReader("text that won't mean anything")
req, err := http.NewRequest(http.MethodGet, "http://example.com/foo", iKnowThisBodyShouldBeIgnored)
if err != nil {
    panic(err)
}
res, err := http.DefaultClient.Do(req)

solved How to send JSON body in GET request golang?