相当于go http请求有效载荷中的curl --data

For the purpose of setting a K/V in a NoSQL storage, I need to create an equivalent to the following curl command in go:

curl -H "Content-Type: text/xml" --data '[...]' http://localhost:8000/test/testrow/test:testcolumn

I am trying to use something in the lines of the following code for that purpose, although I am unable to find how to set the binary data []byte(value) as a POST payload.

func setColumn(table string, key string, col string, value string) {

url := "http://localhost:8123/" + table + "/" + key + "/" + col
req, err := http.NewRequest("POST", url, nil)
req.Header.Set("Content-Type", "application/octet-stream")

data = []byte(value)

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
    // handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))

}

So, how to map the data payload within the POST request ? Any indicators are welcome.

In order to post any data you should pass the value instead of nil in the Newrequest method.

This should work

func setColumn(table string, key string, col string, value string) {

    url := "http://localhost:8123/" + table + "/" + key + "/" + col
    **data := bytes.NewReader([]byte(value))**
    req, err := http.NewRequest("POST", url, **data**)
    req.Header.Set("Content-Type", "application/octet-stream")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        // handle error
    }
    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

Most of the NoSQL Servers has GO API use them instad of creating your own HTTP request.