func GetWM(w http.ResponseWriter, r *http.Request) {
//一写代码
//省略掉了
//var TOTID
//r.Method == "GET"
w.Header().Set("Content-Type", "application/json")
resp, err := http.Get("///xxxxx.json")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ :=ioutil.ReadAll(resp.Body)
addthis := fmt.Sprintf(`{"id":"%s",`,TOTID)
body = append([]byte(addthis),body[1:]...)
b=string(body)
fmt.Fprint(w, b)
}
这样写是不是很丑?