亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

相當于 go http 請求負載中的 curl --data

相當于 go http 請求負載中的 curl --data

Go
慕容708150 2021-10-04 15:46:24
為了在 NoSQL 存儲中設置 K/V,我需要在 go 中創建一個等效于以下curl命令的命令:curl -H "Content-Type: text/xml" --data '[...]' http://localhost:8000/test/testrow/test:testcolumn我正在嘗試為此目的使用以下代碼行中的某些內容,盡管我無法找到如何將二進制數據 []byte(value) 設置為 POST 有效負載。func setColumn(table string, key string, col string, value string) {url := "http://localhost:8123/" + table + "/" + key + "/" + colreq, 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))}那么,如何在 POST 請求中映射數據負載?歡迎任何指標。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 200 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號