如何在Go中使用正文执行GET请求?

I am trying to write a client for an internal API endpoint that accepts a GET request with a JSON body:

curl -X GET -d '{"foo":"bar"}' <my api>

Since I can't change the API to accept a POST, I assumed implementing the same thing in Go would be trivial, but I haven't been able to get this to work.

I've tried to model my attempt after this example of a URL encoded POST request but not sure how I would alter this to work with a GET request.

Thanks in advance

This ended up working:

stmt := `{"foo": "bar"}`
req, err := http.NewRequest("GET", "<api>", bytes.NewBuffer([]byte(stmt)))

resp, _ := client.Do(r)