https://www.jianshu.com/p/bd6fc894e7be
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://127.0.0.1:5000/api/version/resources/resource_item"
fmt.Println("URL:>", url)
// 使用转义反引号完成json转换
item := "testKey"
updateParams := `{"testKey":"` + item + `"}`
var jsonStr = []byte(updateParams)
req, _ := http.NewRequest(http.MethodPatch, url, bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
fmt.Println("response Status:", resp.Status)
fmt.Println("response Headers:", resp.Header)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("response Body:", string(body))
}